Text search cannot do both stemming and logical AND

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Querying, Text Search
    • Query Integration
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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.

              Assignee:
              [DO NOT USE] Backlog - Query Integration
              Reporter:
              Sean Reilly
              Votes:
              1 Vote for this issue
              Watchers:
              9 Start watching this issue

                Created:
                Updated: