Hi. I have what seems to me as a strange problem and I'm at a loss with it:
Let's take:
tags = [ ObjectId('a'), ObjectId('b') ]
search = { $search: 'abc' }
Now the following query works fine:
db.entries.find({ $or: [ {$text:search} ] })
And this one too:
db.entries.find({ $or: [ {tags:{$in:tags}} ] })
But combine them:
db.entries.find({ $or: [ {$text:search}, {tags:{$in:tags}} ] })
And I get the following error:
Unable to execute query: error processing query: ns=db.entries
Tree:
$or
tags $in [ ObjectId('a'), ObjectId('b') ]
TEXT : query=abc, language=, tag=NULL
Sort: {}
Proj: {}
No query solutions
2.6.4
.{_id:"c"}
expression works fine.$or
-array doesn't influence the outcome.Help? :(
While MongoDB's full-text search features may not be as robust as those of some dedicated search engines, they are capable enough for many use cases. Note that there are more search query modifiers — such as case and diacritic sensitivity and support for multiple languages — within a single text index.
MongoDB text search uses the Snowball stemming library to reduce words to an expected root form (or stem) based on common language rules. Algorithmic stemming provides a quick reduction, but languages have exceptions (such as irregular or contradicting verb conjugation patterns) that can affect accuracy.
Compare Full-Text Search queries to the LIKE predicate A LIKE query against millions of rows of text data can take minutes to return; whereas a full-text query can take only seconds or less against the same data, depending on the number of rows that are returned.
Conclusion. Users searching full text are more likely to find relevant articles than searching only abstracts. This finding affirms the value of full text collections for text retrieval and provides a starting point for future work in exploring algorithms that take advantage of rapidly-growing digital archives.
Running the query under a slightly different environment produced a much more clear error:
Runner error: BadValue error processing query: ns=webistor.entries limit=0 skip=0
Tree: $or
tags $in [ ObjectId('a') ObjectId('b') ]
TEXT : query=abc, language=, tag=NULL
Sort: {}
Proj: {}
planner returned error: Failed to produce a solution for TEXT under OR - other non-TEXT clauses under OR have to be indexed as well.
Note
Other non-TEXT clauses under OR have to be indexed as well
Apparently I'll have to add an index to tags
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With