At the very least you probably want $and:
http://jira.mongodb.org/browse/SERVER-1089
(btw, I graduated from Mira Costa)
Thanks for your answer, that's probably what I'll end up doing, it is
still really slow but a few times faster than using $where.
Hopefully the introduction of the $and operator will allow me to come
up with the long-term solution.
Thanks,
Bartlomiej "veyDer" Rudzki
2011/1/16 Nat <nat....@gmail.com>:
Here's an example of the query:
> db.HighSchoolStudent.find({
... search_keywords:{
... $all:[ /\bbart/i, /\brudzki/i, /\bmanhattan/i, /\bbeach/i ]
... }
... }).explain()
{
"cursor" : "BasicCursor",
"nscanned" : 112421,
"nscannedObjects" : 112421,
"n" : 1,
"millis" : 1430,
"indexBounds" : {
}
}
My original query (with $where) took between 5000 and 6000ms, so it's
a step in the good direction.
Now the thing is that I perform ~20-30 additional counts for faceted
search on each search results page. While all other queries take less
time (as each of them is filtered by another indexed property like age
group, region, etc.), the general loading time of the page is
unacceptable (~15000ms).
At the moment I'm modifying the code to use lowercased keywords, so I
can get rid of "i" flag from the regex (which prevents the index),
that should also help.