# Text or term, setup similar as 'tweet' demo does not seem to work with the term query

**URL:** <https://discuss.elastic.co/t/text-or-term-setup-similar-as-tweet-demo-does-not-seem-to-work-with-the-term-query/10845>\
**Category:** Elasticsearch\
**Created:** [February 21, 2013, 5:59pm UTC](https://discuss.elastic.co/t/text-or-term-setup-similar-as-tweet-demo-does-not-seem-to-work-with-the-term-query/10845 "2013-02-21T17:59:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![olger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/olger/32/1918_2.png) [@olger](https://discuss.elastic.co/u/olger)\
**Post date:** [February 21, 2013, 5:59pm UTC](https://discuss.elastic.co/t/text-or-term-setup-similar-as-tweet-demo-does-not-seem-to-work-with-the-term-query/10845/1 "2013-02-21T17:59:22Z")

</div>

Hi List,

I'm interested to integrate elasticsearch in one of our projects and  
started some simple research to understand how this can be done.  
Now, I try to get a situation that allows me to query on something and  
limit the results by filtering on 'terms'

In my first setup, I tried to re-play the tweet example with my own data  
and found that my query with 'term' (not terms yet) does not work  
curl -XPOST 'localhost:9200/tip/\_search?pretty=true' -d  
'{"query":{"term":{"name":"Installation"}}}'

When I change to 'text' it does work :

curl -XPOST 'localhost:9200/tip/\_search?pretty=true' -d  
'{"query":{"text":{"name":"Installation"}}}'

Any idea what could be wrong ?

I have added a gist with the full sample, creating an index, 2 documents of  
a certain type (project) and with the 2 queries.  
This is all done on a clean 0.20.5 installation.

> <https://gist.github.com/olger/5006648>

Kind regards,

Olger

--  
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:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [February 21, 2013, 6:14pm UTC](https://discuss.elastic.co/t/text-or-term-setup-similar-as-tweet-demo-does-not-seem-to-work-with-the-term-query/10845/2 "2013-02-21T18:14:21Z")

</div>

Hi Olger,

the 'term' query works like a keyword query. It searches for fields that  
match the given term exactly. But, by default, each field that does not  
declare an analyzer is analyzed by the standard analyzer. So the 'name'  
field in your example. The standard analyzer performs lowercase  
conversion (and some more). That is the reason why a 'term' query, which  
is case sensitive, does not succeed in giving results for  
'Installation'. It works as expected!

You have some options: declare an analyzer for the field that is not  
lowercasing (for example, the keyword analyzer), or remove analyzers for  
the field (by setting it to no\_analyzed), or use 'text' instead of  
'term' (the 'text' query is the preferred type of generic query).

N.B. you do not want to store the 'name' field, I'm quite sure.

Jörg

--  
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:** ![olger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/olger/32/1918_2.png) [@olger](https://discuss.elastic.co/u/olger)\
**Post date:** [February 21, 2013, 7:09pm UTC](https://discuss.elastic.co/t/text-or-term-setup-similar-as-tweet-demo-does-not-seem-to-work-with-the-term-query/10845/3 "2013-02-21T19:09:10Z")

</div>

Hi Jorg,

Indeed, it works as expected. Thanks for your detailed explanation, this  
gives some starting points to get the data organised in a way that will  
work with a filter.

Kind regards,

Olger

BTW: thanks for your hint on the name storage, it's a left-over of various  
try-outs and I'll remove it.

On Thursday, February 21, 2013 7:14:21 PM UTC+1, Jörg Prante wrote:

> Hi Olger,
> 
> the 'term' query works like a keyword query. It searches for fields that  
> match the given term exactly. But, by default, each field that does not  
> declare an analyzer is analyzed by the standard analyzer. So the 'name'  
> field in your example. The standard analyzer performs lowercase  
> conversion (and some more). That is the reason why a 'term' query, which  
> is case sensitive, does not succeed in giving results for  
> 'Installation'. It works as expected!
> 
> You have some options: declare an analyzer for the field that is not  
> lowercasing (for example, the keyword analyzer), or remove analyzers for  
> the field (by setting it to no\_analyzed), or use 'text' instead of  
> 'term' (the 'text' query is the preferred type of generic query).
> 
> N.B. you do not want to store the 'name' field, I'm quite sure.
> 
> Jörg

--  
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:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 21, 2013, 7:21pm UTC](https://discuss.elastic.co/t/text-or-term-setup-similar-as-tweet-demo-does-not-seem-to-work-with-the-term-query/10845/4 "2013-02-21T19:21:18Z")

</div>

BTW text query is deprecated. Use match query instead.

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 21 févr. 2013 à 20:09, olger@spectare.nl a écrit :

Hi Jorg,

Indeed, it works as expected. Thanks for your detailed explanation, this gives some starting points to get the data organised in a way that will work with a filter.

Kind regards,

Olger

BTW: thanks for your hint on the name storage, it's a left-over of various try-outs and I'll remove it.

On Thursday, February 21, 2013 7:14:21 PM UTC+1, Jörg Prante wrote:

> Hi Olger,
> 
> the 'term' query works like a keyword query. It searches for fields that  
> match the given term exactly. But, by default, each field that does not  
> declare an analyzer is analyzed by the standard analyzer. So the 'name'  
> field in your example. The standard analyzer performs lowercase  
> conversion (and some more). That is the reason why a 'term' query, which  
> is case sensitive, does not succeed in giving results for  
> 'Installation'. It works as expected!
> 
> You have some options: declare an analyzer for the field that is not  
> lowercasing (for example, the keyword analyzer), or remove analyzers for  
> the field (by setting it to no\_analyzed), or use 'text' instead of  
> 'term' (the 'text' query is the preferred type of generic query).
> 
> N.B. you do not want to store the 'name' field, I'm quite sure.
> 
> Jörg

--  
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).

--  
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:** ![olger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/olger/32/1918_2.png) [@olger](https://discuss.elastic.co/u/olger)\
**Post date:** [February 21, 2013, 7:41pm UTC](https://discuss.elastic.co/t/text-or-term-setup-similar-as-tweet-demo-does-not-seem-to-work-with-the-term-query/10845/5 "2013-02-21T19:41:37Z")

</div>

Hi David,

Thanks. Updated the full gist to show an existing example with a match  
query and a filter on terms

> <https://gist.github.com/olger/5006648>

Kind regards,

Olger

On Thursday, February 21, 2013 8:21:18 PM UTC+1, David Pilato wrote:

> BTW text query is deprecated. Use match query instead.
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 21 févr. 2013 à 20:09, ol...@spectare.nl \<javascript:\> a écrit :
> 
> Hi Jorg,
> 
> Indeed, it works as expected. Thanks for your detailed explanation, this  
> gives some starting points to get the data organised in a way that will  
> work with a filter.
> 
> Kind regards,
> 
> Olger
> 
> BTW: thanks for your hint on the name storage, it's a left-over of various  
> try-outs and I'll remove it.
> 
> On Thursday, February 21, 2013 7:14:21 PM UTC+1, Jörg Prante wrote:
> 
> > Hi Olger,
> > 
> > the 'term' query works like a keyword query. It searches for fields that  
> > match the given term exactly. But, by default, each field that does not  
> > declare an analyzer is analyzed by the standard analyzer. So the 'name'  
> > field in your example. The standard analyzer performs lowercase  
> > conversion (and some more). That is the reason why a 'term' query, which  
> > is case sensitive, does not succeed in giving results for  
> > 'Installation'. It works as expected!
> > 
> > You have some options: declare an analyzer for the field that is not  
> > lowercasing (for example, the keyword analyzer), or remove analyzers for  
> > the field (by setting it to no\_analyzed), or use 'text' instead of  
> > 'term' (the 'text' query is the preferred type of generic query).
> > 
> > N.B. you do not want to store the 'name' field, I'm quite sure.
> > 
> > Jörg
> 
> --  
> 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:\>.  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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:50am UTC](https://discuss.elastic.co/t/text-or-term-setup-similar-as-tweet-demo-does-not-seem-to-work-with-the-term-query/10845/6 "2017-07-06T02:50:12Z")

</div>


