1
votes

I have two ES queries:

{match:{text:{query: "text box", type: "phrase"}}}
{match:{text:{query: "text bo", type: "phrase_prefix"}}}

The problem is that the second query returns fewer documents than the first one, although I would expect the second query to return all records from the first one plus something extra. What am I missing?

Thanks

1
Is your text field not_analyzed or analyzed with something similar to keyword?Andrei Stefan
We're using standard built-in analyzer.Alex B

1 Answers

2
votes

This could be due to max_expansions being set to its default value 10

Try this

{
  "query": {
    "match_phrase_prefix": {
      "text": {
        "query": "text bo",
        "max_expansions": 100
      }
    }
  }
}

This thread will help you understand how terms are expanded. make max_expansions 1000 and see the results.

Basically you have lot of words starting with bo like bond, boss and since 'x' comes last alphabetically, you are not getting what you expect.

I hope this helps!