# 0.90: search\_string vs match\_phrase\_prefix: same query different results

**URL:** https://discuss.elastic.co/t/0-90-search-string-vs-match-phrase-prefix-same-query-different-results/11810
**Category:** Elasticsearch
**Created:** [May 4, 2013, 9:46am UTC](https://discuss.elastic.co/t/0-90-search-string-vs-match-phrase-prefix-same-query-different-results/11810 "2013-05-04T09:46:52Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Serge\_Aluker](https://avatars.discourse-cdn.com/v4/letter/s/85f322/32.png) [@Serge\_Aluker](https://discuss.elastic.co/u/Serge_Aluker)
#### Post date: [May 4, 2013, 9:46am UTC](https://discuss.elastic.co/t/0-90-search-string-vs-match-phrase-prefix-same-query-different-results/11810/1 "2013-05-04T09:46:52Z")

</div>

I am trying the following two search queries in the recently released 0.90:

{  
"query\_string" : {  
"query" : "object:Geo\*"  
}

and

{  
"match\_phrase\_prefix" : {  
"object" : "Geo"  
}

The first one returns the correct total (53603472) and the second one  
returns 11453280. An example doc that didn't match the second query and  
should have: {"object":"Geo:Thailand:Bangkok"}

Mapping is just  
{"properties":{"object":{"type":"string"}}}

What is causing the difference between the two queries?

Thanks!  
Serge

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Serge\_Aluker](https://avatars.discourse-cdn.com/v4/letter/s/85f322/32.png) [@Serge\_Aluker](https://discuss.elastic.co/u/Serge_Aluker)
#### Post date: [May 7, 2013, 4:17am UTC](https://discuss.elastic.co/t/0-90-search-string-vs-match-phrase-prefix-same-query-different-results/11810/2 "2013-05-07T04:17:32Z")

</div>

For others finding this issue, I figured out the answer:

match\_phrase\_prefix by default sets the max\_expansions to 50 (I had to  
figure out this default value by trial and error -- not in the docs that I  
could find).

after settings max\_expansions to 1000, the two queries below became  
equivalent:

{  
"query\_string" : {  
"query" : "object:Geo\*"  
}

{  
"match\_phrase\_prefix": {  
"object": {  
"query": "Geo",  
"max\_expansions": 1000  
}  
}  
}

It looks like query\_string's prefix format does not have a  
max\_expansions-like limit.

Hope this helps someone.

Serge

On Saturday, May 4, 2013 5:46:52 AM UTC-4, Serge Aluker wrote:

> I am trying the following two search queries in the recently released 0.90:
> 
> {  
> "query\_string" : {  
> "query" : "object:Geo\*"  
> }
> 
> and
> 
> {  
> "match\_phrase\_prefix" : {  
> "object" : "Geo"  
> }
> 
> The first one returns the correct total (53603472) and the second one  
> returns 11453280. An example doc that didn't match the second query and  
> should have: {"object":"Geo:Thailand:Bangkok"}
> 
> Mapping is just  
> {"properties":{"object":{"type":"string"}}}
> 
> What is causing the difference between the two queries?
> 
> Thanks!  
> Serge

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:38am UTC](https://discuss.elastic.co/t/0-90-search-string-vs-match-phrase-prefix-same-query-different-results/11810/3 "2017-07-06T02:38:00Z")

</div>


