Search query issue using "term" and spaces

Sorry to bother you about another probably-simple issue I'm having.

When I'm using a query to search, with the "term" query, and the field
I'm searching for has a space in it, I can't find it. When there is no
space in the field I am searching for, I can find things.

Example below:

curl -XPUT http://localhost:9200/twitter/tweet/1 -d '{

"user" : "kim chy",
"message" : "test message"
}'
{"ok":true,"_index":"twitter","_type":"tweet","_id":"1"}

curl -XGET http://localhost:9200/twitter/tweet/_search -d '{

"query" : { "term" : { "user" : "kim chy" } }
}'
{"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":
0,"max_score":null,"hits":}}

curl -XPUT http://localhost:9200/twitter/tweet/1 -d '{
"user" : "kimchy",
"message" : "test message"
}'
{"ok":true,"_index":"twitter","_type":"tweet","_id":"1"}

curl -XGET http://localhost:9200/twitter/tweet/_search -d '{
"query" : { "term" : { "user" : "kimchy" } }
}'
{"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":
1,"max_score":1.5108256,"hits":
[{"_index":"twitter","_type":"tweet","_id":"1","_score":1.5108256,
"_source" : {
"user" : "kimchy",
"message" : "test message"
}}]}}

Thank you for your time

When a field (like user) is "analyzed", the content gets tokenized (by
default) words. In your example, if you want to be able to search as "kim
chy" the field should not be analyzed. You can have multi field mappings to
have both analyzed and not analyzed versions as well. These links may help:

www.elasticsearch.com/docs/elasticsearch/mapping/multi_field/
www.elasticsearch.com/docs/elasticsearch/index_modules/analysis/
http://www.elasticsearch.com/docs/elasticsearch/index_modules/analysis/

Regards,
Berkay Mollamustafaoglu
mberkay on yahoo, google and skype

On Tue, Aug 3, 2010 at 7:43 PM, elastic searcher
elasticsearcher@gmail.comwrote:

Sorry to bother you about another probably-simple issue I'm having.

When I'm using a query to search, with the "term" query, and the field
I'm searching for has a space in it, I can't find it. When there is no
space in the field I am searching for, I can find things.

Example below:

curl -XPUT http://localhost:9200/twitter/tweet/1 -d '{

"user" : "kim chy",
"message" : "test message"
}'
{"ok":true,"_index":"twitter","_type":"tweet","_id":"1"}

curl -XGET http://localhost:9200/twitter/tweet/_search -d '{

"query" : { "term" : { "user" : "kim chy" } }
}'
{"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":
0,"max_score":null,"hits":}}

curl -XPUT http://localhost:9200/twitter/tweet/1 -d '{
"user" : "kimchy",
"message" : "test message"
}'
{"ok":true,"_index":"twitter","_type":"tweet","_id":"1"}

curl -XGET http://localhost:9200/twitter/tweet/_search -d '{
"query" : { "term" : { "user" : "kimchy" } }
}'
{"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":
1,"max_score":1.5108256,"hits":
[{"_index":"twitter","_type":"tweet","_id":"1","_score":1.5108256,
"_source" : {
"user" : "kimchy",
"message" : "test message"
}}]}}

Thank you for your time

Also, note that the analysis process is also relevant when searching. The
term query do no analysis on the searched text (its a term). The field query
analyzes the text, breaks it into terms, and constructs a query to try and
match on them.

-shay.banon

On Wed, Aug 4, 2010 at 3:01 AM, Berkay Mollamustafaoglu
mberkay@gmail.comwrote:

When a field (like user) is "analyzed", the content gets tokenized (by
default) words. In your example, if you want to be able to search as "kim
chy" the field should not be analyzed. You can have multi field mappings to
have both analyzed and not analyzed versions as well. These links may help:

www.elasticsearch.com/docs/elasticsearch/mapping/multi_field/
Analysis | Elasticsearch Guide [8.11] | Elastic
http://www.elasticsearch.com/docs/elasticsearch/index_modules/analysis/

Regards,
Berkay Mollamustafaoglu
mberkay on yahoo, google and skype

On Tue, Aug 3, 2010 at 7:43 PM, elastic searcher <
elasticsearcher@gmail.com> wrote:

Sorry to bother you about another probably-simple issue I'm having.

When I'm using a query to search, with the "term" query, and the field
I'm searching for has a space in it, I can't find it. When there is no
space in the field I am searching for, I can find things.

Example below:

curl -XPUT http://localhost:9200/twitter/tweet/1 -d '{

"user" : "kim chy",
"message" : "test message"
}'
{"ok":true,"_index":"twitter","_type":"tweet","_id":"1"}

curl -XGET http://localhost:9200/twitter/tweet/_search -d '{

"query" : { "term" : { "user" : "kim chy" } }
}'
{"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":
0,"max_score":null,"hits":}}

curl -XPUT http://localhost:9200/twitter/tweet/1 -d '{
"user" : "kimchy",
"message" : "test message"
}'
{"ok":true,"_index":"twitter","_type":"tweet","_id":"1"}

curl -XGET http://localhost:9200/twitter/tweet/_search -d '{
"query" : { "term" : { "user" : "kimchy" } }
}'
{"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":
1,"max_score":1.5108256,"hits":
[{"_index":"twitter","_type":"tweet","_id":"1","_score":1.5108256,
"_source" : {
"user" : "kimchy",
"message" : "test message"
}}]}}

Thank you for your time

Thanks guys.

If all I wanted to be able to do was to A) search based on individual
words in a field (like the default mapping), and B) search based on
entire terms, could I use the "store" attribute of the string type and
set it to 'yes' (it defaults to 'no') in order to additionally be able
to search for the exact term?

Or would I have to use a multi-mapping in order to store both analyzed
and non-analyzed versions of the field?

In my system, I would like to be able to search my test results by
word tokens, but I also need to be able to determine if a particular
result is already inserted, so as not to insert another, identical,
result, and for that, I need to be able to query for the entire term
(or if there's a better way, please enlighten me)

Thanks again for your time.

On Aug 3, 11:01 pm, Shay Banon shay.ba...@elasticsearch.com wrote:

Also, note that the analysis process is also relevant when searching. The
term query do no analysis on the searched text (its a term). The field query
analyzes the text, breaks it into terms, and constructs a query to try and
match on them.

-shay.banon

On Wed, Aug 4, 2010 at 3:01 AM, Berkay Mollamustafaoglu
mber...@gmail.comwrote:

When a field (like user) is "analyzed", the content gets tokenized (by
default) words. In your example, if you want to be able to search as "kim
chy" the field should not be analyzed. You can have multi field mappings to
have both analyzed and not analyzed versions as well. These links may help:

www.elasticsearch.com/docs/elasticsearch/mapping/multi_field/
Analysis | Elasticsearch Guide [8.11] | Elastic
http://www.elasticsearch.com/docs/elasticsearch/index_modules/analysis/

Regards,
Berkay Mollamustafaoglu
mberkay on yahoo, google and skype

On Tue, Aug 3, 2010 at 7:43 PM, elastic searcher <
elasticsearc...@gmail.com> wrote:

Sorry to bother you about another probably-simple issue I'm having.

When I'm using a query to search, with the "term" query, and the field
I'm searching for has a space in it, I can't find it. When there is no
space in the field I am searching for, I can find things.

Example below:

curl -XPUThttp://localhost:9200/twitter/tweet/1-d '{

"user" : "kim chy",
"message" : "test message"
}'
{"ok":true,"_index":"twitter","_type":"tweet","_id":"1"}

curl -XGEThttp://localhost:9200/twitter/tweet/_search-d '{

"query" : { "term" : { "user" : "kim chy" } }
}'
{"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":
0,"max_score":null,"hits":}}

curl -XPUThttp://localhost:9200/twitter/tweet/1-d '{
"user" : "kimchy",
"message" : "test message"
}'
{"ok":true,"_index":"twitter","_type":"tweet","_id":"1"}

curl -XGEThttp://localhost:9200/twitter/tweet/_search-d '{
"query" : { "term" : { "user" : "kimchy" } }
}'
{"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":
1,"max_score":1.5108256,"hits":
[{"_index":"twitter","_type":"tweet","_id":"1","_score":1.5108256,
"_source" : {
"user" : "kimchy",
"message" : "test message"
}}]}}

Thank you for your time

If you want to query by a "single" term, then you set it to be not_analyzed
on the index mapping. store has nothing to do with the analysis process, it
just controls if you can fetch the field "on its own", without the _source,
when you search.

-shay.banon

On Wed, Aug 4, 2010 at 6:31 PM, elastic searcher
elasticsearcher@gmail.comwrote:

Thanks guys.

If all I wanted to be able to do was to A) search based on individual
words in a field (like the default mapping), and B) search based on
entire terms, could I use the "store" attribute of the string type and
set it to 'yes' (it defaults to 'no') in order to additionally be able
to search for the exact term?

Or would I have to use a multi-mapping in order to store both analyzed
and non-analyzed versions of the field?

In my system, I would like to be able to search my test results by
word tokens, but I also need to be able to determine if a particular
result is already inserted, so as not to insert another, identical,
result, and for that, I need to be able to query for the entire term
(or if there's a better way, please enlighten me)

Thanks again for your time.

On Aug 3, 11:01 pm, Shay Banon shay.ba...@elasticsearch.com wrote:

Also, note that the analysis process is also relevant when searching. The
term query do no analysis on the searched text (its a term). The field
query
analyzes the text, breaks it into terms, and constructs a query to try
and
match on them.

-shay.banon

On Wed, Aug 4, 2010 at 3:01 AM, Berkay Mollamustafaoglu
mber...@gmail.comwrote:

When a field (like user) is "analyzed", the content gets tokenized (by
default) words. In your example, if you want to be able to search as
"kim
chy" the field should not be analyzed. You can have multi field
mappings to
have both analyzed and not analyzed versions as well. These links may
help:

www.elasticsearch.com/docs/elasticsearch/mapping/multi_field/
Analysis | Elasticsearch Guide [8.11] | Elastic
<
Analysis | Elasticsearch Guide [8.11] | Elastic>

Regards,
Berkay Mollamustafaoglu
mberkay on yahoo, google and skype

On Tue, Aug 3, 2010 at 7:43 PM, elastic searcher <
elasticsearc...@gmail.com> wrote:

Sorry to bother you about another probably-simple issue I'm having.

When I'm using a query to search, with the "term" query, and the field
I'm searching for has a space in it, I can't find it. When there is no
space in the field I am searching for, I can find things.

Example below:

curl -XPUThttp://localhost:9200/twitter/tweet/1-d '{

"user" : "kim chy",
"message" : "test message"
}'
{"ok":true,"_index":"twitter","_type":"tweet","_id":"1"}

curl -XGEThttp://localhost:9200/twitter/tweet/_search-d '{

"query" : { "term" : { "user" : "kim chy" } }
}'
{"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":
0,"max_score":null,"hits":}}

curl -XPUThttp://localhost:9200/twitter/tweet/1-d '{
"user" : "kimchy",
"message" : "test message"
}'
{"ok":true,"_index":"twitter","_type":"tweet","_id":"1"}

curl -XGEThttp://localhost:9200/twitter/tweet/_search-d '{
"query" : { "term" : { "user" : "kimchy" } }
}'
{"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":
1,"max_score":1.5108256,"hits":
[{"_index":"twitter","_type":"tweet","_id":"1","_score":1.5108256,
"_source" : {
"user" : "kimchy",
"message" : "test message"
}}]}}

Thank you for your time

Awesome, thanks.

One more question.

If I want to have every string in a type (or every string in my
Elasticsearch datastore) both analyzed and non-analyzed, is there any
way I can do this easily?

The documentation shows examples which detail the particular
properties within a type having non-default analyzers, but is there
any way to have the same non-default analyzers for all properties
within a type?

Thanks again.

On Aug 4, 10:28 am, Shay Banon shay.ba...@elasticsearch.com wrote:

If you want to query by a "single" term, then you set it to be not_analyzed
on the index mapping. store has nothing to do with the analysis process, it
just controls if you can fetch the field "on its own", without the _source,
when you search.

-shay.banon

On Wed, Aug 4, 2010 at 6:31 PM, elastic searcher
elasticsearc...@gmail.comwrote:

Thanks guys.

If all I wanted to be able to do was to A) search based on individual
words in a field (like the default mapping), and B) search based on
entire terms, could I use the "store" attribute of the string type and
set it to 'yes' (it defaults to 'no') in order to additionally be able
to search for the exact term?

Or would I have to use a multi-mapping in order to store both analyzed
and non-analyzed versions of the field?

In my system, I would like to be able to search my test results by
word tokens, but I also need to be able to determine if a particular
result is already inserted, so as not to insert another, identical,
result, and for that, I need to be able to query for the entire term
(or if there's a better way, please enlighten me)

Thanks again for your time.

On Aug 3, 11:01 pm, Shay Banon shay.ba...@elasticsearch.com wrote:

Also, note that the analysis process is also relevant when searching. The
term query do no analysis on the searched text (its a term). The field
query
analyzes the text, breaks it into terms, and constructs a query to try
and
match on them.

-shay.banon

On Wed, Aug 4, 2010 at 3:01 AM, Berkay Mollamustafaoglu
mber...@gmail.comwrote:

When a field (like user) is "analyzed", the content gets tokenized (by
default) words. In your example, if you want to be able to search as
"kim
chy" the field should not be analyzed. You can have multi field
mappings to
have both analyzed and not analyzed versions as well. These links may
help:

www.elasticsearch.com/docs/elasticsearch/mapping/multi_field/
Analysis | Elasticsearch Guide [8.11] | Elastic
<
Analysis | Elasticsearch Guide [8.11] | Elastic>

Regards,
Berkay Mollamustafaoglu
mberkay on yahoo, google and skype

On Tue, Aug 3, 2010 at 7:43 PM, elastic searcher <
elasticsearc...@gmail.com> wrote:

Sorry to bother you about another probably-simple issue I'm having.

When I'm using a query to search, with the "term" query, and the field
I'm searching for has a space in it, I can't find it. When there is no
space in the field I am searching for, I can find things.

Example below:

curl -XPUThttp://localhost:9200/twitter/tweet/1-d'{

"user" : "kim chy",
"message" : "test message"
}'
{"ok":true,"_index":"twitter","_type":"tweet","_id":"1"}

curl -XGEThttp://localhost:9200/twitter/tweet/_search-d'{

"query" : { "term" : { "user" : "kim chy" } }
}'
{"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":
0,"max_score":null,"hits":}}

curl -XPUThttp://localhost:9200/twitter/tweet/1-d'{
"user" : "kimchy",
"message" : "test message"
}'
{"ok":true,"_index":"twitter","_type":"tweet","_id":"1"}

curl -XGEThttp://localhost:9200/twitter/tweet/_search-d'{
"query" : { "term" : { "user" : "kimchy" } }
}'
{"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":
1,"max_score":1.5108256,"hits":
[{"_index":"twitter","_type":"tweet","_id":"1","_score":1.5108256,
"_source" : {
"user" : "kimchy",
"message" : "test message"
}}]}}

Thank you for your time

No, there isn't a magic mapping setting that will enable it... . You will
have to do it by hand for now... . Note that an existing field mapping can
be "upgraded" to multi field mapping when new mapping definition is merged
with an existing one.

-shay.banon

On Wed, Aug 4, 2010 at 8:59 PM, elastic searcher
elasticsearcher@gmail.comwrote:

Awesome, thanks.

One more question.

If I want to have every string in a type (or every string in my
Elasticsearch datastore) both analyzed and non-analyzed, is there any
way I can do this easily?

The documentation shows examples which detail the particular
properties within a type having non-default analyzers, but is there
any way to have the same non-default analyzers for all properties
within a type?

Thanks again.

On Aug 4, 10:28 am, Shay Banon shay.ba...@elasticsearch.com wrote:

If you want to query by a "single" term, then you set it to be
not_analyzed
on the index mapping. store has nothing to do with the analysis process,
it
just controls if you can fetch the field "on its own", without the
_source,
when you search.

-shay.banon

On Wed, Aug 4, 2010 at 6:31 PM, elastic searcher
elasticsearc...@gmail.comwrote:

Thanks guys.

If all I wanted to be able to do was to A) search based on individual
words in a field (like the default mapping), and B) search based on
entire terms, could I use the "store" attribute of the string type and
set it to 'yes' (it defaults to 'no') in order to additionally be able
to search for the exact term?

Or would I have to use a multi-mapping in order to store both analyzed
and non-analyzed versions of the field?

In my system, I would like to be able to search my test results by
word tokens, but I also need to be able to determine if a particular
result is already inserted, so as not to insert another, identical,
result, and for that, I need to be able to query for the entire term
(or if there's a better way, please enlighten me)

Thanks again for your time.

On Aug 3, 11:01 pm, Shay Banon shay.ba...@elasticsearch.com wrote:

Also, note that the analysis process is also relevant when searching.
The
term query do no analysis on the searched text (its a term). The
field
query
analyzes the text, breaks it into terms, and constructs a query to
try
and
match on them.

-shay.banon

On Wed, Aug 4, 2010 at 3:01 AM, Berkay Mollamustafaoglu
mber...@gmail.comwrote:

When a field (like user) is "analyzed", the content gets tokenized
(by
default) words. In your example, if you want to be able to search
as
"kim
chy" the field should not be analyzed. You can have multi field
mappings to
have both analyzed and not analyzed versions as well. These links
may
help:

www.elasticsearch.com/docs/elasticsearch/mapping/multi_field/
Analysis | Elasticsearch Guide [8.11] | Elastic
<
Analysis | Elasticsearch Guide [8.11] | Elastic

Regards,
Berkay Mollamustafaoglu
mberkay on yahoo, google and skype

On Tue, Aug 3, 2010 at 7:43 PM, elastic searcher <
elasticsearc...@gmail.com> wrote:

Sorry to bother you about another probably-simple issue I'm
having.

When I'm using a query to search, with the "term" query, and the
field
I'm searching for has a space in it, I can't find it. When there
is no
space in the field I am searching for, I can find things.

Example below:

curl -XPUThttp://localhost:9200/twitter/tweet/1-d'{

"user" : "kim chy",
"message" : "test message"
}'
{"ok":true,"_index":"twitter","_type":"tweet","_id":"1"}

curl -XGEThttp://localhost:9200/twitter/tweet/_search-d'{

"query" : { "term" : { "user" : "kim chy" } }
}'
{"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":
0,"max_score":null,"hits":}}

curl -XPUThttp://localhost:9200/twitter/tweet/1-d'{
"user" : "kimchy",
"message" : "test message"
}'
{"ok":true,"_index":"twitter","_type":"tweet","_id":"1"}

curl -XGEThttp://localhost:9200/twitter/tweet/_search-d'{
"query" : { "term" : { "user" : "kimchy" } }
}'
{"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":
1,"max_score":1.5108256,"hits":
[{"_index":"twitter","_type":"tweet","_id":"1","_score":1.5108256,
"_source" : {
"user" : "kimchy",
"message" : "test message"
}}]}}

Thank you for your time