Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-18633

Text search cannot do both stemming and logical AND

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

      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:
            backlog-query-integration [DO NOT USE] Backlog - Query Integration
            Reporter:
            seanjreilly Sean Reilly
            Votes:
            1 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated: