# Why do term queries and query\_string queries produce different results for the same query?

**URL:** https://discuss.elastic.co/t/why-do-term-queries-and-query-string-queries-produce-different-results-for-the-same-query/14853
**Category:** Elasticsearch
**Created:** [December 13, 2013, 1:47pm UTC](https://discuss.elastic.co/t/why-do-term-queries-and-query-string-queries-produce-different-results-for-the-same-query/14853 "2013-12-13T13:47:06Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![project2501](https://avatars.discourse-cdn.com/v4/letter/p/41988e/32.png) [@project2501](https://discuss.elastic.co/u/project2501)
#### Post date: [December 13, 2013, 1:47pm UTC](https://discuss.elastic.co/t/why-do-term-queries-and-query-string-queries-produce-different-results-for-the-same-query/14853/1 "2013-12-13T13:47:06Z")

</div>

If I have a term query that is simple text:people  
and then I have a query\_string that is also "text:people" they produce  
different number of results.

Why is that?

thank you!

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/2999d8e5-fea8-4e8a-b928-dfb8391056e6%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2999d8e5-fea8-4e8a-b928-dfb8391056e6%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![johtani](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/johtani/32/44956_2.png) [@johtani](https://discuss.elastic.co/u/johtani)
#### Post date: [December 13, 2013, 2:59pm UTC](https://discuss.elastic.co/t/why-do-term-queries-and-query-string-queries-produce-different-results-for-the-same-query/14853/2 "2013-12-13T14:59:27Z")

</div>

Hi,

term query is not analyze a given term, directly search inverted index.

> **[Elastic — The Search AI Company](https://www.elastic.co)**
>
> Power insights and outcomes with The Elastic Search AI Platform. See into your data and find answers that matter with enterprise solutions designed to help you accelerate time to insight. Try Elastic ...

query\_string query is analyze a given term using analyzer defined the field  
(your example : "text").

> **[Elastic — The Search AI Company](https://www.elastic.co)**
>
> Power insights and outcomes with The Elastic Search AI Platform. See into your data and find answers that matter with enterprise solutions designed to help you accelerate time to insight. Try Elastic ...

What kind of analyzer is "text" field?

regards,

Jun Ohtani

2013/12/13 project2501 [darreng5150@gmail.com](mailto:darreng5150@gmail.com)

> If I have a term query that is simple text:people  
> and then I have a query\_string that is also "text:people" they produce  
> different number of results.
> 
> Why is that?
> 
> thank you!
> 
> --  
> 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).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/2999d8e5-fea8-4e8a-b928-dfb8391056e6%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2999d8e5-fea8-4e8a-b928-dfb8391056e6%40googlegroups.com)  
> .  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

## --

Jun Ohtani  
blog : [http://blog.johtani.info](http://blog.johtani.info)

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAPW8A5z4\_rXqEHBw2AK%3D%2BWXPS8fr7ibjaVqEaGVsw9oFdgszhQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPW8A5z4_rXqEHBw2AK%3D%2BWXPS8fr7ibjaVqEaGVsw9oFdgszhQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![project2501](https://avatars.discourse-cdn.com/v4/letter/p/41988e/32.png) [@project2501](https://discuss.elastic.co/u/project2501)
#### Post date: [December 13, 2013, 3:08pm UTC](https://discuss.elastic.co/t/why-do-term-queries-and-query-string-queries-produce-different-results-for-the-same-query/14853/3 "2013-12-13T15:08:23Z")

</div>

snowball

On Friday, December 13, 2013 9:59:27 AM UTC-5, Jun Ohtani wrote:

> Hi,
> 
> term query is not analyze a given term, directly search inverted index.
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-term-query.html)
> 
> query\_string query is analyze a given term using analyzer defined the  
> field (your example : "text").
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html)
> 
> What kind of analyzer is "text" field?
> 
> regards,
> 
> Jun Ohtani
> 
> 2013/12/13 project2501 \<[darre...@gmail.com](mailto:darre...@gmail.com) \<javascript:\>\>
> 
> > If I have a term query that is simple text:people  
> > and then I have a query\_string that is also "text:people" they produce  
> > different number of results.
> > 
> > Why is that?
> > 
> > thank you!
> > 
> > --  
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/2999d8e5-fea8-4e8a-b928-dfb8391056e6%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2999d8e5-fea8-4e8a-b928-dfb8391056e6%40googlegroups.com)  
> > .  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> ## --
> 
> Jun Ohtani  
> blog : [http://blog.johtani.info](http://blog.johtani.info)

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/e72d0a6d-1cf0-4769-9aab-ece6c8fef347%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e72d0a6d-1cf0-4769-9aab-ece6c8fef347%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![johtani](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/johtani/32/44956_2.png) [@johtani](https://discuss.elastic.co/u/johtani)
#### Post date: [December 13, 2013, 3:15pm UTC](https://discuss.elastic.co/t/why-do-term-queries-and-query-string-queries-produce-different-results-for-the-same-query/14853/4 "2013-12-13T15:15:20Z")

</div>

Hi

snowball analyzer stem last "e".

You run following command :  
[http://localhost:9200/\_analyze?analyzer=snowball&text=people&pretty](http://localhost:9200/_analyze?analyzer=snowball&text=people&pretty)

You receive following response.

{  
"tokens" : [ {  
"token" : "peopl",  
"start\_offset" : 0,  
"end\_offset" : 6,  
"type" : "",  
"position" : 1  
} ]  
}

query\_string query search "peopl" term, but term query search "people".  
If you use term "peopl", then the number of results using term query is  
equal the number of results using query\_string query.

regards,

2013/12/14 project2501 [darreng5150@gmail.com](mailto:darreng5150@gmail.com)

> snowball
> 
> On Friday, December 13, 2013 9:59:27 AM UTC-5, Jun Ohtani wrote:
> 
> > Hi,
> > 
> > term query is not analyze a given term, directly search inverted index.  
> > [Elastic — The Search AI Company | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/)  
> > reference/current/query-dsl-term-query.html
> > 
> > query\_string query is analyze a given term using analyzer defined the  
> > field (your example : "text").  
> > [Elastic — The Search AI Company | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/)  
> > reference/current/query-dsl-query-string-query.html
> > 
> > What kind of analyzer is "text" field?
> > 
> > regards,
> > 
> > Jun Ohtani
> > 
> > 2013/12/13 project2501 [darre...@gmail.com](mailto:darre...@gmail.com)
> > 
> > > If I have a term query that is simple text:people  
> > > and then I have a query\_string that is also "text:people" they produce  
> > > different number of results.
> > > 
> > > Why is that?
> > > 
> > > thank you!
> > > 
> > > --  
> > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).
> > > 
> > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > msgid/elasticsearch/2999d8e5-fea8-4e8a-b928-dfb8391056e6%  
> > > [40googlegroups.com](http://40googlegroups.com).  
> > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> > 
> > ## --
> > 
> > Jun Ohtani  
> > blog : [http://blog.johtani.info](http://blog.johtani.info)
> 
> --  
> 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).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/e72d0a6d-1cf0-4769-9aab-ece6c8fef347%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e72d0a6d-1cf0-4769-9aab-ece6c8fef347%40googlegroups.com)  
> .
> 
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

## --

Jun Ohtani  
blog : [http://blog.johtani.info](http://blog.johtani.info)

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAPW8A5wPevPVP\_skn3BiSReRMFHKnaBq95%2BNUQveagwMXTB2eQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPW8A5wPevPVP_skn3BiSReRMFHKnaBq95%2BNUQveagwMXTB2eQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![project2501](https://avatars.discourse-cdn.com/v4/letter/p/41988e/32.png) [@project2501](https://discuss.elastic.co/u/project2501)
#### Post date: [December 13, 2013, 3:59pm UTC](https://discuss.elastic.co/t/why-do-term-queries-and-query-string-queries-produce-different-results-for-the-same-query/14853/5 "2013-12-13T15:59:17Z")

</div>

Thank you for the help. Very appreciated! It makes a lot of sense now.

On Friday, December 13, 2013 10:15:20 AM UTC-5, Jun Ohtani wrote:

> Hi
> 
> snowball analyzer stem last "e".
> 
> You run following command :  
> [http://localhost:9200/\_analyze?analyzer=snowball&text=people&pretty](http://localhost:9200/_analyze?analyzer=snowball&text=people&pretty)
> 
> You receive following response.
> 
> {  
> "tokens" : [ {  
> "token" : "peopl",  
> "start\_offset" : 0,  
> "end\_offset" : 6,  
> "type" : "",  
> "position" : 1  
> } ]  
> }
> 
> query\_string query search "peopl" term, but term query search "people".  
> If you use term "peopl", then the number of results using term query is  
> equal the number of results using query\_string query.
> 
> regards,
> 
> 2013/12/14 project2501 \<[darre...@gmail.com](mailto:darre...@gmail.com) \<javascript:\>\>
> 
> > snowball
> > 
> > On Friday, December 13, 2013 9:59:27 AM UTC-5, Jun Ohtani wrote:
> > 
> > > Hi,
> > > 
> > > term query is not analyze a given term, directly search inverted index.  
> > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/)  
> > > reference/current/query-dsl-term-query.html
> > > 
> > > query\_string query is analyze a given term using analyzer defined the  
> > > field (your example : "text").  
> > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/)  
> > > reference/current/query-dsl-query-string-query.html
> > > 
> > > What kind of analyzer is "text" field?
> > > 
> > > regards,
> > > 
> > > Jun Ohtani
> > > 
> > > 2013/12/13 project2501 [darre...@gmail.com](mailto:darre...@gmail.com)
> > > 
> > > > If I have a term query that is simple text:people  
> > > > and then I have a query\_string that is also "text:people" they produce  
> > > > different number of results.
> > > > 
> > > > Why is that?
> > > > 
> > > > thank you!
> > > > 
> > > > --  
> > > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).
> > > > 
> > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > msgid/elasticsearch/2999d8e5-fea8-4e8a-b928-dfb8391056e6%  
> > > > [40googlegroups.com](http://40googlegroups.com).  
> > > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> > > 
> > > ## --
> > > 
> > > Jun Ohtani  
> > > blog : [http://blog.johtani.info](http://blog.johtani.info)
> > 
> > --  
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/e72d0a6d-1cf0-4769-9aab-ece6c8fef347%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e72d0a6d-1cf0-4769-9aab-ece6c8fef347%40googlegroups.com)  
> > .
> > 
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> ## --
> 
> Jun Ohtani  
> blog : [http://blog.johtani.info](http://blog.johtani.info)

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/2625f243-3b51-45cc-8666-aba072d4ec3d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2625f243-3b51-45cc-8666-aba072d4ec3d%40googlegroups.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:01am UTC](https://discuss.elastic.co/t/why-do-term-queries-and-query-string-queries-produce-different-results-for-the-same-query/14853/6 "2017-07-06T02:01:18Z")

</div>


