# Understaning terms syntax

**URL:** https://discuss.elastic.co/t/understaning-terms-syntax/20883
**Category:** Elasticsearch
**Created:** [November 21, 2014, 5:45am UTC](https://discuss.elastic.co/t/understaning-terms-syntax/20883 "2014-11-21T05:45:57Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![GX1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gx1/32/62846_2.png) [@GX1](https://discuss.elastic.co/u/GX1)
#### Post date: [November 21, 2014, 5:45am UTC](https://discuss.elastic.co/t/understaning-terms-syntax/20883/1 "2014-11-21T05:45:57Z")

</div>

Hi All

Im having the following scenario (elasticsearch 1.0):  
the query  
"query": {  
"term": {  
"ac": "3A822F3B-3ECF-4463-98F86DF6DE28EC5C"  
}  
}

yields no results

but this works

"query": {  
"query\_string" : {  
"default\_field" : "ac",  
"query" : "3A822F3B-3ECF-4463-98F86DF6DE28EC5C"  
}  
}

the problem is when I combine it with a "must\_not" or "not" filter I still  
get the same results

what is the correct syntax I need?

Thanks

GX

--  
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/a1f4c507-f85a-4ebd-b71f-4962259abf5a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a1f4c507-f85a-4ebd-b71f-4962259abf5a%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2014, 1:53pm UTC](https://discuss.elastic.co/t/understaning-terms-syntax/20883/2 "2014-12-06T13:53:00Z")

</div>

Hi GX,

“term" query does NOT analyzed your string.  
See: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-term-query.html#query-dsl-term-query)

On the other hand, “query\_string” query analyze your string.

If you want to know the difference, you can use \_validate API.  
See : [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-validate.html#search-validate)

Example commands are as follows:

GET hoge/fuga/\_validate/query?explain  
{  
"query": {  
"term": {  
"ac": "3A822F3B-3ECF-4463-98F86DF6DE28EC5C"  
}  
}  
}

GET hoge/fuga/\_validate/query?explain  
{  
"query": {  
"query\_string" : {  
"default\_field" : "ac",  
"query" : "3A822F3B-3ECF-4463-98F86DF6DE28EC5C"  
}  
}  
}

I hope that those help you out.

* * *

Jun Ohtani  
[johtani@gmail.com](mailto:johtani@gmail.com)  
blog : [http://blog.johtani.info](http://blog.johtani.info)  
twitter : [http://twitter.com/johtani](http://twitter.com/johtani)

> 2014/11/21 14:45、GX [mailme.gx@gmail.com](mailto:mailme.gx@gmail.com) のメール：
> 
> Hi All
> 
> Im having the following scenario (elasticsearch 1.0):  
> the query  
> "query": {  
> "term": {  
> "ac": "3A822F3B-3ECF-4463-98F86DF6DE28EC5C"  
> }  
> }
> 
> yields no results
> 
> but this works
> 
> "query": {  
> "query\_string" : {  
> "default\_field" : "ac",  
> "query" : "3A822F3B-3ECF-4463-98F86DF6DE28EC5C"  
> }  
> }
> 
> the problem is when I combine it with a "must\_not" or "not" filter I still get the same results
> 
> what is the correct syntax I need?
> 
> Thanks
> 
> GX
> 
> --  
> 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/a1f4c507-f85a-4ebd-b71f-4962259abf5a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a1f4c507-f85a-4ebd-b71f-4962259abf5a%40googlegroups.com).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/634B3D51-39A8-469D-938A-A6F5BCDA2D67%40gmail.com](https://groups.google.com/d/msgid/elasticsearch/634B3D51-39A8-469D-938A-A6F5BCDA2D67%40gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![GX1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gx1/32/62846_2.png) [@GX1](https://discuss.elastic.co/u/GX1)
#### Post date: [December 6, 2014, 3:18pm UTC](https://discuss.elastic.co/t/understaning-terms-syntax/20883/3 "2014-12-06T15:18:47Z")

</div>

Hi Jun,

thanks for the reply will look into this

GX

On Saturday, December 6, 2014 3:53:10 PM UTC+2, Jun Ohtani wrote:

> Hi GX,
> 
> “term" query does NOT analyzed your string.  
> See:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-term-query.html#query-dsl-term-query)
> 
> On the other hand, “query\_string” query analyze your string.
> 
> If you want to know the difference, you can use \_validate API.  
> See :  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-validate.html#search-validate)
> 
> Example commands are as follows:
> 
> GET hoge/fuga/\_validate/query?explain  
> {  
> "query": {  
> "term": {  
> "ac": "3A822F3B-3ECF-4463-98F86DF6DE28EC5C"  
> }  
> }  
> }
> 
> GET hoge/fuga/\_validate/query?explain  
> {  
> "query": {  
> "query\_string" : {  
> "default\_field" : "ac",  
> "query" : "3A822F3B-3ECF-4463-98F86DF6DE28EC5C"  
> }  
> }  
> }
> 
> I hope that those help you out.
> 
> * * *
> 
> Jun Ohtani  
> [joh...@gmail.com](mailto:joh...@gmail.com) \<javascript:\>  
> blog : [http://blog.johtani.info](http://blog.johtani.info)  
> twitter : [http://twitter.com/johtani](http://twitter.com/johtani)
> 
> > 2014/11/21 14:45、GX \<[mail...@gmail.com](mailto:mail...@gmail.com) \<javascript:\>\> のメール：
> > 
> > Hi All
> > 
> > Im having the following scenario (elasticsearch 1.0):  
> > the query  
> > "query": {  
> > "term": {  
> > "ac": "3A822F3B-3ECF-4463-98F86DF6DE28EC5C"  
> > }  
> > }
> > 
> > yields no results
> > 
> > but this works
> > 
> > "query": {  
> > "query\_string" : {  
> > "default\_field" : "ac",  
> > "query" : "3A822F3B-3ECF-4463-98F86DF6DE28EC5C"  
> > }  
> > }
> > 
> > the problem is when I combine it with a "must\_not" or "not" filter I  
> > still get the same results
> > 
> > what is the correct syntax I need?
> > 
> > Thanks
> > 
> > GX
> > 
> > --  
> > 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/a1f4c507-f85a-4ebd-b71f-4962259abf5a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a1f4c507-f85a-4ebd-b71f-4962259abf5a%40googlegroups.com).
> 
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/9dfabbb3-ff0f-459c-bfbc-b69632076dda%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/9dfabbb3-ff0f-459c-bfbc-b69632076dda%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)
#### Post date: [December 6, 2014, 3:26pm UTC](https://discuss.elastic.co/t/understaning-terms-syntax/20883/4 "2014-12-06T15:26:19Z")

</div>

Also, its usually better to use a "match" query if you want to analyze the  
query rather than "query\_string". Query string exposes a huge array of  
syntax which is both useful and terribly dangerous. Users can write  
regexes and huge range queries and fuzzy queries that use much much more  
cpu and ram than the term and phrase queries you expect them to write.

Nik

On Sat, Dec 6, 2014 at 10:18 AM, GX [mailme.gx@gmail.com](mailto:mailme.gx@gmail.com) wrote:

> Hi Jun,
> 
> thanks for the reply will look into this
> 
> GX
> 
> On Saturday, December 6, 2014 3:53:10 PM UTC+2, Jun Ohtani wrote:
> 
> > Hi GX,
> > 
> > “term" query does NOT analyzed your string.  
> > See: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/)  
> > reference/current/query-dsl-term-query.html#query-dsl-term-query
> > 
> > On the other hand, “query\_string” query analyze your string.
> > 
> > If you want to know the difference, you can use \_validate API.  
> > See : [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/)  
> > reference/current/search-validate.html#search-validate
> > 
> > Example commands are as follows:
> > 
> > GET hoge/fuga/\_validate/query?explain  
> > {  
> > "query": {  
> > "term": {  
> > "ac": "3A822F3B-3ECF-4463-98F86DF6DE28EC5C"  
> > }  
> > }  
> > }
> > 
> > GET hoge/fuga/\_validate/query?explain  
> > {  
> > "query": {  
> > "query\_string" : {  
> > "default\_field" : "ac",  
> > "query" : "3A822F3B-3ECF-4463-98F86DF6DE28EC5C"  
> > }  
> > }  
> > }
> > 
> > I hope that those help you out.
> > 
> > * * *
> > 
> > Jun Ohtani  
> > [joh...@gmail.com](mailto:joh...@gmail.com)  
> > blog : [http://blog.johtani.info](http://blog.johtani.info)  
> > twitter : [http://twitter.com/johtani](http://twitter.com/johtani)
> > 
> > > 2014/11/21 14:45、GX [mail...@gmail.com](mailto:mail...@gmail.com) のメール：
> > > 
> > > Hi All
> > > 
> > > Im having the following scenario (elasticsearch 1.0):  
> > > the query  
> > > "query": {  
> > > "term": {  
> > > "ac": "3A822F3B-3ECF-4463-98F86DF6DE28EC5C"  
> > > }  
> > > }
> > > 
> > > yields no results
> > > 
> > > but this works
> > > 
> > > "query": {  
> > > "query\_string" : {  
> > > "default\_field" : "ac",  
> > > "query" : "3A822F3B-3ECF-4463-98F86DF6DE28EC5C"  
> > > }  
> > > }
> > > 
> > > the problem is when I combine it with a "must\_not" or "not" filter I  
> > > still get the same results
> > > 
> > > what is the correct syntax I need?
> > > 
> > > Thanks
> > > 
> > > GX
> > > 
> > > --  
> > > 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/a1f4c507-f85a-4ebd-b71f-4962259abf5a%  
> > > [40googlegroups.com](http://40googlegroups.com).  
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > 
> > --  
> > 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/9dfabbb3-ff0f-459c-bfbc-b69632076dda%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/9dfabbb3-ff0f-459c-bfbc-b69632076dda%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/9dfabbb3-ff0f-459c-bfbc-b69632076dda%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/9dfabbb3-ff0f-459c-bfbc-b69632076dda%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/CAPmjWd0rFhUPwAowxdi4Su\_U%2Bvw1J6Ptr\_r-EVe2f1jHqH-80w%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPmjWd0rFhUPwAowxdi4Su_U%2Bvw1J6Ptr_r-EVe2f1jHqH-80w%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:45am UTC](https://discuss.elastic.co/t/understaning-terms-syntax/20883/5 "2017-07-06T00:45:18Z")

</div>


