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

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.

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.
For more options, visit https://groups.google.com/groups/opt_out.

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.
For more options, visit https://groups.google.com/groups/opt_out.

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.
For more options, visit https://groups.google.com/groups/opt_out.

BTW text query is deprecated. Use match query instead.

--
David :wink:
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.
For more options, visit 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.
For more options, visit https://groups.google.com/groups/opt_out.

Hi David,

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

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 :wink:
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 <javascript:>.
For more options, visit 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.
For more options, visit https://groups.google.com/groups/opt_out.