From: Rob Moore <robert.allanb...@gmail.com>
Date: Tue, 11 Sep 2012 18:47:29 -0700 (PDT)
Local: Tues, Sep 11 2012 9:47 pm
Subject: Re: Query by Array size in Java driver
So the $size operator only matches if the size is exact. You can achieve the effect you want using the $exists operator and the "." The shell code is like: } } ) Basically saying "match an array with a second element". Indexes are zero based. The Java side looks like: If you use the Asynchronous driver<http://www.allanbank.com/mongodb-async-driver/>that turns into: DocumentAssignable query = QueryBuilder<http://www.allanbank.com/mongodb-async-driver/apidocs/index.html?com/...> .and("myArray.1").exists(); Rob On Tuesday, September 11, 2012 5:06:20 PM UTC-4, shekhar agrawal wrote:
> I am using this query in Mongo shell and getting desired result. > db.MyCollection.find( {"owner":"abc" , $where: "if ( ( this.myArray && > Return all documents where the array "myArray" is not null and its size is > I am finding it hard to implement this in Java. > BasicDBObject query = new BasicDBObject("owner", "abc"); > How could I query for all documents having the size of the array "to" > Thanks, You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||