This doesn't work
FindIterable<Document> result = db.getCollection(resourceName)
.find(Filters.eq("time", "1262599860000"))
.batchSize(batchSize)
.skip(offset);
But the field is NumberLong, so it should ? And the below does work :
FindIterable<Document> result = db.getCollection(resourceName)
.find(Filters.gt("time", 100))
.batchSize(batchSize)
.skip(offset);
How do I correctly specify a long value to a MongoDb filter via java ? The mongo shell shows :
db.events.find({time:1262599860000})
{ "_id" : "507f191e810c19729de8aae3", "type" : "LOGIN", "time" : NumberLong("1262599860000"), "user" : "[email protected]", "ip" : "192.168.1.13" }
Longand treat it asNumberLongwhen converting to BSON. Neither your string or default numeric value are aLong. So cast as one. BTWbatchSize()is not alimit()as you appear to be assuming by using in combination withskip(). That's just a method for setting the number of results returned in the "cursor fetch" ( a low level internal thing ) as a "get more" operation. But it does not limit the number of results returned.FindIterablebased on the syntax above. At any rate the correct method should belimit()in ALL implementations. Just asbatchSize()does the same thing in ALL implementations. Which is again, not what you seem to want here.