# Search query issue using "term" and spaces

**URL:** <https://discuss.elastic.co/t/search-query-issue-using-term-and-spaces/3186>\
**Category:** Elasticsearch\
**Created:** [August 3, 2010, 11:43pm UTC](https://discuss.elastic.co/t/search-query-issue-using-term-and-spaces/3186 "2010-08-03T23:43:09Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![elasticsearcher](https://avatars.discourse-cdn.com/v4/letter/e/7ba0ec/32.png) [@elasticsearcher](https://discuss.elastic.co/u/elasticsearcher)\
**Post date:** [August 3, 2010, 11:43pm UTC](https://discuss.elastic.co/t/search-query-issue-using-term-and-spaces/3186/1 "2010-08-03T23:43:09Z")

</div>

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](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](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](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](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

---

<div class="post-metadata">

**Author:** ![Berkay\_Mollamustafao](https://avatars.discourse-cdn.com/v4/letter/b/22d042/32.png) [@Berkay\_Mollamustafao](https://discuss.elastic.co/u/Berkay_Mollamustafao)\
**Post date:** [August 4, 2010, 12:01am UTC](https://discuss.elastic.co/t/search-query-issue-using-term-and-spaces/3186/2 "2010-08-04T00:01:19Z")

</div>

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/](http://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/)  
[http://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.com](mailto: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](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](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](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](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

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [August 4, 2010, 6:01am UTC](https://discuss.elastic.co/t/search-query-issue-using-term-and-spaces/3186/3 "2010-08-04T06:01:37Z")

</div>

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.com](mailto:mberkay@gmail.com)wrote:

> 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/](http://www.elasticsearch.com/docs/elasticsearch/mapping/multi_field/)  
> [Analysis | Elasticsearch Guide [8.11] | Elastic](http://www.elasticsearch.com/docs/elasticsearch/index_modules/analysis/)  
> [http://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.com](mailto: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](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](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](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](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

---

<div class="post-metadata">

**Author:** ![elasticsearcher](https://avatars.discourse-cdn.com/v4/letter/e/7ba0ec/32.png) [@elasticsearcher](https://discuss.elastic.co/u/elasticsearcher)\
**Post date:** [August 4, 2010, 3:31pm UTC](https://discuss.elastic.co/t/search-query-issue-using-term-and-spaces/3186/4 "2010-08-04T15:31:22Z")

</div>

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](mailto: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.com](mailto:mber...@gmail.com)wrote:
> 
> > 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/](http://www.elasticsearch.com/docs/elasticsearch/mapping/multi_field/)  
> > [Analysis | Elasticsearch Guide [8.11] | Elastic](http://www.elasticsearch.com/docs/elasticsearch/index_modules/analysis/)  
> > [http://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 \<  
> > [elasticsearc...@gmail.com](mailto: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

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [August 4, 2010, 5:28pm UTC](https://discuss.elastic.co/t/search-query-issue-using-term-and-spaces/3186/5 "2010-08-04T17:28:29Z")

</div>

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.com](mailto:elasticsearcher@gmail.com)wrote:

> 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](mailto: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.com](mailto:mber...@gmail.com)wrote:
> > 
> > > 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/](http://www.elasticsearch.com/docs/elasticsearch/mapping/multi_field/)  
> > > [Analysis | Elasticsearch Guide [8.11] | Elastic](http://www.elasticsearch.com/docs/elasticsearch/index_modules/analysis/)  
> > > \<  
> > > [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](mailto: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

---

<div class="post-metadata">

**Author:** ![elasticsearcher](https://avatars.discourse-cdn.com/v4/letter/e/7ba0ec/32.png) [@elasticsearcher](https://discuss.elastic.co/u/elasticsearcher)\
**Post date:** [August 4, 2010, 5:59pm UTC](https://discuss.elastic.co/t/search-query-issue-using-term-and-spaces/3186/6 "2010-08-04T17:59:23Z")

</div>

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](mailto: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.com](mailto:elasticsearc...@gmail.com)wrote:
> 
> > 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](mailto: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.com](mailto:mber...@gmail.com)wrote:
> 
> > > > 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/](http://www.elasticsearch.com/docs/elasticsearch/mapping/multi_field/)  
> > > > [Analysis | Elasticsearch Guide [8.11] | Elastic](http://www.elasticsearch.com/docs/elasticsearch/index_modules/analysis/)  
> > > > \<  
> > > > [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](mailto: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

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [August 4, 2010, 7:14pm UTC](https://discuss.elastic.co/t/search-query-issue-using-term-and-spaces/3186/7 "2010-08-04T19:14:55Z")

</div>

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.com](mailto:elasticsearcher@gmail.com)wrote:

> 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](mailto: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.com](mailto:elasticsearc...@gmail.com)wrote:
> > 
> > > 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](mailto: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.com](mailto:mber...@gmail.com)wrote:
> > 
> > > > > 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/](http://www.elasticsearch.com/docs/elasticsearch/mapping/multi_field/)  
> > > > > [Analysis | Elasticsearch Guide [8.11] | Elastic](http://www.elasticsearch.com/docs/elasticsearch/index_modules/analysis/)  
> > > > > \<  
> > > > > [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](mailto: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

---

<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, 4:21am UTC](https://discuss.elastic.co/t/search-query-issue-using-term-and-spaces/3186/8 "2017-07-06T04:21:10Z")

</div>


