# Search returns no results for partial string

**URL:** <https://discuss.elastic.co/t/search-returns-no-results-for-partial-string/101793>\
**Category:** Elasticsearch\
**Created:** [September 26, 2017, 7:14am UTC](https://discuss.elastic.co/t/search-returns-no-results-for-partial-string/101793 "2017-09-26T07:14:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![amiexc](https://avatars.discourse-cdn.com/v4/letter/a/71c47a/32.png) [@amiexc](https://discuss.elastic.co/u/amiexc)\
**Post date:** [September 26, 2017, 7:14am UTC](https://discuss.elastic.co/t/search-returns-no-results-for-partial-string/101793/1 "2017-09-26T07:14:58Z")

</div>

Hello,

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:  
{"query":{  
"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!

---

<div class="post-metadata">

**Author:** ![abdon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abdon/32/9195_2.png) [@abdon](https://discuss.elastic.co/u/abdon)\
**Post date:** [September 26, 2017, 1:51pm UTC](https://discuss.elastic.co/t/search-returns-no-results-for-partial-string/101793/2 "2017-09-26T13:51:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![amiexc](https://avatars.discourse-cdn.com/v4/letter/a/71c47a/32.png) [@amiexc](https://discuss.elastic.co/u/amiexc)\
**Post date:** [September 26, 2017, 11:57pm UTC](https://discuss.elastic.co/t/search-returns-no-results-for-partial-string/101793/3 "2017-09-26T23:57:08Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 24, 2017, 11:57pm UTC](https://discuss.elastic.co/t/search-returns-no-results-for-partial-string/101793/4 "2017-10-24T23:57:14Z")

</div>

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