Details
-
Improvement
-
Resolution: Unresolved
-
Major - P3
-
None
-
None
-
Query Integration
Description
By default providing a list of words separated by spaces performs a search to find any of the specified words (logical OR), with stemming of each word. Logical AND isn't supported.
The common workaround to perform a logical AND seems to be to wrap each word in quotes to do phrase matching. However, this has the side effect of disabling stemming.
Steps to reproduce:
1. Insert some data
use textSearch
|
db.foo.createIndex({"$**": "text"})
|
db.foo.save({phrase: "phrase includes foo"})
|
db.foo.save({phrase: "phrase includes bar"})
|
2. Returning both inserted documents using the query terms "including" and "foo" with stemming and a logical OR is possible:
db.foo.find({$text: {$search: "including foo"}}).count()
|
3. Using an exact phrase matching to create a logical and without stemming to find one document is possible:
db.foo.find({$text: {$search: "\"includes\" \"foo\""}}).count()
|
4. Combining the logical and with word stemming to return only the first inserted document using the query terms "including" and "foo" doesn't seem to be possible.