Search returns no results for partial string


I have a document with field "name": "Hotel Relais Fontana Di Trevi", indexed using the default (standard) analyser.
I am running a search on this field with the string "fontana di tre" and max expansions 100 and get no results. when using max expansions 1000 I am getting my document in the results (and another matching document).
I only have 2 documents that actually match the partial string search, shouldn't max_expansions=2 be enough? That's how I understood the max_expansions documentation at least...

My search query is:
"bool" : {
"must" :
"match_phrase_prefix" : {
"name" : {
"query" : "fontana di tre",
"slop" : 0,
"max_expansions" : 100,
"boost" : 1.0
"disable_coord" : false,
"adjust_pure_negative" : true,
"boost" : 1.0

Thanks for any help!

The way "max_expansions" : 100 works is that for the last term in your match_phrase_prefix query (tre), it will take the first 100 terms that start with tre that actually occur in your dataset, and run an OR query on those terms.

So, let's say your documents have a field name that contains the values treA, treB, treC, treD and treE. If you would run a match_phrase_prefix query with "max_expansions" : 3 your actual query would be for: treA OR treB or treC and as a result you would miss those documents that contain the values treD or treE.

In your case, it looks like you have more than a 100 terms for the name field that start with tre. As a result, with a "max_expansions" : 100 you are not finding the document containing Trevi, but when you change "max_expansions" to 1000 you are able to find that document.

Thank you very much for your clarification, I missed the part that it's searching per word so I may have 100 matches to the last word but I won't actually see 100 results.

I will switch to proper autocomplete to get more consistent results.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.