# Inconsistent results for the text\_phrase\_prefix search

**URL:** <https://discuss.elastic.co/t/inconsistent-results-for-the-text-phrase-prefix-search/5578>\
**Category:** Elasticsearch\
**Created:** [October 12, 2011, 12:53pm UTC](https://discuss.elastic.co/t/inconsistent-results-for-the-text-phrase-prefix-search/5578 "2011-10-12T12:53:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![frazer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/frazer/32/2752_2.png) [@frazer](https://discuss.elastic.co/u/frazer)\
**Post date:** [October 12, 2011, 12:53pm UTC](https://discuss.elastic.co/t/inconsistent-results-for-the-text-phrase-prefix-search/5578/1 "2011-10-12T12:53:06Z")

</div>

I seem to be getting inconsistent/unpredictable results for the  
text\_phrase\_prefix search on 0.17.8 that im using for an  
autocomplete. I have supplied an example in the following gist.  
Maybe I'm miss understanding how the query works.

> <https://gist.github.com/frazerh/1281147>

Please note that each time i delete and recreate this index I'm  
getting different results for the text\_phrase\_prefix search examples  
in the gist. Should they be consistent?

Thanks

Frazer

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [October 12, 2011, 9:21pm UTC](https://discuss.elastic.co/t/inconsistent-results-for-the-text-phrase-prefix-search/5578/2 "2011-10-12T21:21:21Z")

</div>

This realtes to the document distributed across the shards. You use auto  
generates ids, which means each time, the documents will end up in different  
shards. Thats fine, but, a score of a document is, by default, computed  
against the documents that exists within the same shard (its "local" to the  
shard). If you want more "correct" results, with scoring the spans the  
cluster, you can set the search\_type to dfs\_query\_then\_fetch, though, it is  
a slower search.

On Wed, Oct 12, 2011 at 2:53 PM, frazer [frazer.horn@gmail.com](mailto:frazer.horn@gmail.com) wrote:

> I seem to be getting inconsistent/unpredictable results for the  
> text\_phrase\_prefix search on 0.17.8 that im using for an  
> autocomplete. I have supplied an example in the following gist.  
> Maybe I'm miss understanding how the query works.
> 
> [Elasticsearch text phrase prefix search with expansion · GitHub](https://gist.github.com/1281147)
> 
> Please note that each time i delete and recreate this index I'm  
> getting different results for the text\_phrase\_prefix search examples  
> in the gist. Should they be consistent?
> 
> Thanks
> 
> Frazer

---

<div class="post-metadata">

**Author:** ![SG1](https://avatars.discourse-cdn.com/v4/letter/s/3e96dc/32.png) [@SG1](https://discuss.elastic.co/u/SG1)\
**Post date:** [May 9, 2013, 12:48pm UTC](https://discuss.elastic.co/t/inconsistent-results-for-the-text-phrase-prefix-search/5578/3 "2013-05-09T12:48:00Z")

</div>

Hi Kimchy,

I am facing same kind of issue without specifying the max\_expansion. From the document I understood that "unbound" is the default for max\_expansion.

I have around 5000000 of records and I am using **text\_phrase\_prefix WITHOUT max\_expansion**. But when I search for single word it resulted properly. But the when I do the search with multiple words with partial second or third word like "San f" then I am not getting the result even I am not getting any max clause exception. If I have set the max\_expansion to 10000 then results are coming properly.

Why default value "unbound" is not considered for max\_expansion. I would appreciate your suggestion for this.

Note: I am using latest Elastic Search Version.

Thanks

---

<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:** [July 6, 2017, 2:37am UTC](https://discuss.elastic.co/t/inconsistent-results-for-the-text-phrase-prefix-search/5578/4 "2017-07-06T02:37:21Z")

</div>


