# Default\_operator=or on query string not honored within paren grouping?

**URL:** <https://discuss.elastic.co/t/default-operator-or-on-query-string-not-honored-within-paren-grouping/136945>\
**Category:** Elasticsearch\
**Created:** [June 21, 2018, 10:02pm UTC](https://discuss.elastic.co/t/default-operator-or-on-query-string-not-honored-within-paren-grouping/136945 "2018-06-21T22:02:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![orogvany](https://avatars.discourse-cdn.com/v4/letter/o/a183cd/32.png) [@orogvany](https://discuss.elastic.co/u/orogvany)\
**Post date:** [June 21, 2018, 10:02pm UTC](https://discuss.elastic.co/t/default-operator-or-on-query-string-not-honored-within-paren-grouping/136945/1 "2018-06-21T22:02:40Z")

</div>

Per the ES docs

> **[Query string query | Elasticsearch Guide \[8.11\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html)**

> where the title field contains quick or brown. If you omit the OR operator the default operator will be used
> 
> title:(quick OR brown)  
> title:(quick brown)

If I do  
{  
"query\_string":{  
"query":"guid:(string1 OR string2)",  
"default\_operator":"or"  
}  
}  
I get 2 results (expected behavior, as there are 2 objects one each with the supplied value for that field). If I remove the 'or'  
{  
"query\_string":{  
"query":"guid:(string1 string2)",  
"default\_operator":"or"  
}  
}  
I get 0 results. It does not appear to honor the default\_operator as described in the docs? This used to work with ES 2.x but on updating to ES 6.3, no dice.

Interestingly, if I add one of the values in quotes, it works  
"query":"guid:(string1 \"string2\")",

Any ideas what I'm missing or what parameter will make this work as documented?  
Thanks!

---

<div class="post-metadata">

**Author:** ![abdon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abdon/32/9195_2.png) [@abdon](https://discuss.elastic.co/u/abdon)\
**Post date:** [June 27, 2018, 12:32pm UTC](https://discuss.elastic.co/t/default-operator-or-on-query-string-not-honored-within-paren-grouping/136945/2 "2018-06-27T12:32:41Z")

</div>

The `guid` field is probably mapped as type `keyword`?

The docs ([Query string query | Elasticsearch Guide [8.11] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html)) have a warning that explains the behavior you're seeing:

> Whitespaces are not considered operators, this means that new york city will be passed "as is" to the analyzer configured for the field. If the field is a keyword field the analyzer will create a single term new york city and the query builder will use this term in the query. If you want to query each term separately you need to add explicit operators around the terms (e.g. new AND york AND city).

---

<div class="post-metadata">

**Author:** ![orogvany](https://avatars.discourse-cdn.com/v4/letter/o/a183cd/32.png) [@orogvany](https://discuss.elastic.co/u/orogvany)\
**Post date:** [July 9, 2018, 8:26pm UTC](https://discuss.elastic.co/t/default-operator-or-on-query-string-not-honored-within-paren-grouping/136945/3 "2018-07-09T20:26:47Z")

</div>

Thanks! Makes sense.

---

<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:** [August 6, 2018, 8:26pm UTC](https://discuss.elastic.co/t/default-operator-or-on-query-string-not-honored-within-paren-grouping/136945/4 "2018-08-06T20:26:51Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
