# How to search for “OR” word inside a Field on ElasticSearch?

**URL:** <https://discuss.elastic.co/t/how-to-search-for-or-word-inside-a-field-on-elasticsearch/12450>\
**Category:** Elasticsearch\
**Created:** [June 17, 2013, 7:41pm UTC](https://discuss.elastic.co/t/how-to-search-for-or-word-inside-a-field-on-elasticsearch/12450 "2013-06-17T19:41:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![poncho1984](https://avatars.discourse-cdn.com/v4/letter/p/53a042/32.png) [@poncho1984](https://discuss.elastic.co/u/poncho1984)\
**Post date:** [June 17, 2013, 7:41pm UTC](https://discuss.elastic.co/t/how-to-search-for-or-word-inside-a-field-on-elasticsearch/12450/1 "2013-06-17T19:41:04Z")

</div>

I´m having a problem when I try to search into a field that stores the  
states acronyms.

I have the next query:

{  
"query": {  
"query\_string": {  
"query": "field\_state:'OR' AND type:incentive"  
}  
}  
}

And the problem comes when i try to get the results for the Oregon State  
(OR). For all the other states works but with this particular one is like  
the Elasticsearch takes the "OR" as a condition an retrieves all.

Is there a way to make this work????, i have try it with terms, prefix  
filters, and all with the same results.

--  
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:** ![dantuff](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@dantuff](https://discuss.elastic.co/u/dantuff)\
**Post date:** [June 17, 2013, 7:57pm UTC](https://discuss.elastic.co/t/how-to-search-for-or-word-inside-a-field-on-elasticsearch/12450/2 "2013-06-17T19:57:13Z")

</div>

Try a should Bool Query:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

On Monday, June 17, 2013 8:41:04 PM UTC+1, Alfonso Noguez wrote:

> I´m having a problem when I try to search into a field that stores the  
> states acronyms.
> 
> I have the next query:
> 
> {  
> "query": {  
> "query\_string": {  
> "query": "field\_state:'OR' AND type:incentive"  
> }  
> }  
> }
> 
> And the problem comes when i try to get the results for the Oregon State  
> (OR). For all the other states works but with this particular one is like  
> the Elasticsearch takes the "OR" as a condition an retrieves all.
> 
> Is there a way to make this work????, i have try it with terms, prefix  
> filters, and all with the same results.

--  
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:** ![sslhj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sslhj/32/119856_2.png) [@sslhj](https://discuss.elastic.co/u/sslhj)\
**Post date:** [June 18, 2013, 5:11am UTC](https://discuss.elastic.co/t/how-to-search-for-or-word-inside-a-field-on-elasticsearch/12450/3 "2013-06-18T05:11:58Z")

</div>

May be you need to escape the ''' with '' or '\\'

---

<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:30am UTC](https://discuss.elastic.co/t/how-to-search-for-or-word-inside-a-field-on-elasticsearch/12450/4 "2017-07-06T02:30:41Z")

</div>


