# String not\_analyzed with whitespaces

**URL:** <https://discuss.elastic.co/t/string-not-analyzed-with-whitespaces/13745>\
**Category:** Elasticsearch\
**Created:** [September 25, 2013, 2:26am UTC](https://discuss.elastic.co/t/string-not-analyzed-with-whitespaces/13745 "2013-09-25T02:26:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![didier\_baquier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/didier_baquier/32/2055_2.png) [@didier\_baquier](https://discuss.elastic.co/u/didier_baquier)\
**Post date:** [September 25, 2013, 2:26am UTC](https://discuss.elastic.co/t/string-not-analyzed-with-whitespaces/13745/1 "2013-09-25T02:26:00Z")

</div>

Hey folks,

I spent my afternoon trying to have a field not analyzed with whitespaces.

I want to index a payment status : Not Paid / Paid, that field must not be  
tokenized.

So, here is my mapping (really basic):  
"label" -\> Map("type" -\> "string", "index" -\> "not\_analyzed", "search" -\>  
"not\_analyzed", "store" -\> "yes")

The following queries work fine, I got my 2 entries:  
{  
"bool" : {  
"must" : {  
"dis\_max" : {  
"tie\_breaker" : 0.7,  
"queries" : [ {  
"field" : {  
"statuses.payment.label" : "Paid"  
}  
}, {  
"field" : {  
"user\_code\_analysis" : {  
"query" : "Paid",  
"boost" : 1.2  
}  
}  
} ]  
}  
}  
}  
}

If I want to do the exact same thing with "Not Paid" instead of Paid :  
{  
"bool" : {  
"must" : {  
"dis\_max" : {  
"tie\_breaker" : 0.7,  
"queries" : [ {  
"field" : {  
"statuses.payment.label" : "Not Paid"  
}  
}, {  
"field" : {  
"user\_code\_analysis" : {  
"query" : "Not Paid",  
"boost" : 1.2  
}  
}  
} ]  
}  
}  
}  
}

The query returns 0 result (normally 1 entry), if I indexed "NotPaid" as a  
status instead of "Not Paid", I've got my entry.

So my issue comes from the whitespace. Am I missing something? Do I need to  
analyze the field?

PS: my mapping is applied, if I execute \_mapping I can see :  
...  
"payment": {  
"properties": {  
....  
"label": {  
"type": "string",  
"index": "not\_analyzed",  
"store": "yes"  
}  
}  
},

thanks for your help

--  
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:** ![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:** [September 25, 2013, 2:58am UTC](https://discuss.elastic.co/t/string-not-analyzed-with-whitespaces/13745/2 "2013-09-25T02:58:38Z")

</div>

Hi,

Field Query is Query String Query .  
"query" is parsed by query parser.

You try to use Term Query instead of Field Query.

* * *

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

On 2013/09/25, at 11:26, [didier.baquier@gmail.com](mailto:didier.baquier@gmail.com) wrote:

> Hey folks,
> 
> I spent my afternoon trying to have a field not analyzed with whitespaces.
> 
> I want to index a payment status : Not Paid / Paid, that field must not be tokenized.
> 
> So, here is my mapping (really basic):  
> "label" -\> Map("type" -\> "string", "index" -\> "not\_analyzed", "search" -\> "not\_analyzed", "store" -\> "yes")
> 
> The following queries work fine, I got my 2 entries:  
> {  
> "bool" : {  
> "must" : {  
> "dis\_max" : {  
> "tie\_breaker" : 0.7,  
> "queries" : [ {  
> "field" : {  
> "statuses.payment.label" : "Paid"  
> }  
> }, {  
> "field" : {  
> "user\_code\_analysis" : {  
> "query" : "Paid",  
> "boost" : 1.2  
> }  
> }  
> } ]  
> }  
> }  
> }  
> }
> 
> If I want to do the exact same thing with "Not Paid" instead of Paid :  
> {  
> "bool" : {  
> "must" : {  
> "dis\_max" : {  
> "tie\_breaker" : 0.7,  
> "queries" : [ {  
> "field" : {  
> "statuses.payment.label" : "Not Paid"  
> }  
> }, {  
> "field" : {  
> "user\_code\_analysis" : {  
> "query" : "Not Paid",  
> "boost" : 1.2  
> }  
> }  
> } ]  
> }  
> }  
> }  
> }
> 
> The query returns 0 result (normally 1 entry), if I indexed "NotPaid" as a status instead of "Not Paid", I've got my entry.
> 
> So my issue comes from the whitespace. Am I missing something? Do I need to analyze the field?
> 
> PS: my mapping is applied, if I execute \_mapping I can see :  
> ...  
> "payment": {  
> "properties": {  
> ....  
> "label": {  
> "type": "string",  
> "index": "not\_analyzed",  
> "store": "yes"  
> }  
> }  
> },
> 
> thanks for your help
> 
> --  
> 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:** ![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:14am UTC](https://discuss.elastic.co/t/string-not-analyzed-with-whitespaces/13745/3 "2017-07-06T02:14:48Z")

</div>


