Right Outer Join

3 November 2011

Filtering on multiple fields in MongoDB

Filed under: JasperReports — Tags: , — mdahlman @ 23:07

Filtering on multiple fields in MongoDB

This thread got me thinking about filtering on multiple fields in a MongoDB query. The author of the original question attempted to use the $and operator which was introduced in MongoDB 2.0. But that’s not needed for simple queries that filter on multiple fields. I created a simple report to show the idea.

Filtering on multiple fields at once in MongoDB

Filtering on multiple fields at once in MongoDB

The report is available here if you want to play with it. Here’s the sample data I used:

db.shiraz.save( { "ServiceType" : "sms", "ServiceHealthState" : "ok", "DocumentID" : "11" } )
db.shiraz.save( { "ServiceType" : "sms", "ServiceHealthState" : "ok", "DocumentID" : "12" } )
db.shiraz.save( { "ServiceType" : "sms", "ServiceHealthState" : "ko", "DocumentID" : "13" } )
db.shiraz.save( { "ServiceType" : "jms", "ServiceHealthState" : "critical", "DocumentID" : "21" } )
db.shiraz.save( { "ServiceType" : "jms", "ServiceHealthState" : "critical", "DocumentID" : "22" } )

If you haven’t used (or heard of!) the Jaspersoft connector for MongoDB, then start with this article.

Advertisement

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Go on... leave a reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Theme: Silver is the New Black. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.