0

I have a query like so.

import play.modules.reactivemongo.json.BSONFormats._
def collection: JSONCollection = db.collection[JSONCollection]("persons")
val q = Json.obj("foo" -> "bar")
collection.find(q).cursor[JsObject].collect[Seq](500)

How do I set $maxScan on this query?

Gabriel
  • 1,679
  • 3
  • 16
  • 37
  • I tried val q = Json.obj("foo"->"bar", "$maxScan"->100) but that did not work. – Gabriel Jan 15 '14 at 00:41
  • Also tried `val q = Json.obj("$query" -> Json.obj("foo"->"bar"), "$maxScan" -> 100)` which does not work either. – Gabriel Jan 15 '14 at 19:03
  • Are you sure you want to set `$maxScan` (limit on documents scanned)? This is different from the [`cursor.limit()`](http://docs.mongodb.org/manual/reference/method/cursor.limit/) value, which is the number of documents that will be returned. For a comparison of usage, you could have a look at this recent question on StackOverflow: [Mongo_mapper limit results](http://stackoverflow.com/questions/20778135/). – Stennie Jan 22 '14 at 14:20
  • @Stennie, Yes I am sure. Limit does not prevent a full collection scan if the query parameters are particularly limiting. I am fully aware that $maxScan will cause indeterminate results. – Gabriel Jan 29 '14 at 23:30

0 Answers0