SlavaG
SlavaG

Reputation: 540

phrase_prefix query returns empty result if I search for 3 characters but returns non-empty result if I search for 4 and more characters

I have this query :

"match": {   
    "_all": {
    "query": "ana",
    "type": "phrase_prefix"
   }
 }

This query does not return anything with phrase "ana" that is 3 characters length, but if I search for 4 characters phrase "anat" it returns result :

match": {
  "_all": {
  "query": "anat",
  "type": "phrase_prefix"
  }
}

What could be the problem here ? I have no idea why is that and how to solve this.

Thanks !!!

Upvotes: 1

Views: 1190

Answers (1)

ChintanShah25
ChintanShah25

Reputation: 12672

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

Try this

{
  "query": {
    "match": {
      "_all": {
        "query": "ana",
        "type": "phrase_prefix",
        "max_expansions": 100
      }
    }
  }
}

Try different values of "max_expansions", do not make it too large otherwise it will take time for query to return

Does this help?

Upvotes: 1

Related Questions