# Query String\_Query and default operator

**URL:** <https://discuss.elastic.co/t/query-string-query-and-default-operator/13729>\
**Category:** Elasticsearch\
**Created:** [September 23, 2013, 8:48pm UTC](https://discuss.elastic.co/t/query-string-query-and-default-operator/13729 "2013-09-23T20:48:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ashwin\_Sathya](https://avatars.discourse-cdn.com/v4/letter/a/b5ac83/32.png) [@Ashwin\_Sathya](https://discuss.elastic.co/u/Ashwin_Sathya)\
**Post date:** [September 23, 2013, 8:48pm UTC](https://discuss.elastic.co/t/query-string-query-and-default-operator/13729/1 "2013-09-23T20:48:01Z")

</div>

Hi,

If I provide a direct query\_string query as "foo bar" ( without the quotes), it gets treated as "foo" OR "bar". Is it possible to change this default behavior. I want it to be defaulted to "foo" AND "bar".

Looking up at Lucene, it looks like it is configured by,

[https://lucene.apache.org/core/4\_1\_0/queryparser/org/apache/lucene/queryparser/classic/QueryParserBase.html#setDefaultOperator(org.apache.lucene.queryparser.classic.QueryParser.Operator)](https://lucene.apache.org/core/4_1_0/queryparser/org/apache/lucene/queryparser/classic/QueryParserBase.html#setDefaultOperator%28org.apache.lucene.queryparser.classic.QueryParser.Operator%29)

Is there a way that I can configure it when running elastic search ??

--  
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:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [September 23, 2013, 8:54pm UTC](https://discuss.elastic.co/t/query-string-query-and-default-operator/13729/2 "2013-09-23T20:54:02Z")

</div>

Look here:

> **[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.

It is called default\_operator.

Nik

On Mon, Sep 23, 2013 at 4:48 PM, R Ashwin Sathya  
[ashwin.sathya@outlook.com](mailto:ashwin.sathya@outlook.com)wrote:

> Hi,
> 
> If I provide a direct query\_string query as "foo bar" ( without the  
> quotes), it gets treated as "foo" OR "bar". Is it possible to change this  
> default behavior. I want it to be defaulted to "foo" AND "bar".
> 
> Looking up at Lucene, it looks like it is configured by,
> 
> [QueryParserBase (Lucene 4.1.0 API)](https://lucene.apache.org/core/4_1_0/queryparser/org/apache/lucene/queryparser/classic/QueryParserBase.html#setDefaultOperator%28org.apache.lucene.queryparser.classic.QueryParser.Operator%29)
> 
> Is there a way that I can configure it when running Elasticsearch ??
> 
> --  
> 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:** ![Ashwin\_Sathya](https://avatars.discourse-cdn.com/v4/letter/a/b5ac83/32.png) [@Ashwin\_Sathya](https://discuss.elastic.co/u/Ashwin_Sathya)\
**Post date:** [September 23, 2013, 8:58pm UTC](https://discuss.elastic.co/t/query-string-query-and-default-operator/13729/3 "2013-09-23T20:58:31Z")

</div>

🙂  
Thanks.

From: [nik9000@gmail.com](mailto:nik9000@gmail.com)  
Date: Mon, 23 Sep 2013 16:54:02 -0400  
Subject: Re: Query String\_Query and default operator  
To: [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com)

Look here: [http://www.elasticsearch.org/guide/reference/query-dsl/query-string-query/](http://www.elasticsearch.org/guide/reference/query-dsl/query-string-query/)  
It is called default\_operator.

Nik

On Mon, Sep 23, 2013 at 4:48 PM, R Ashwin Sathya [ashwin.sathya@outlook.com](mailto:ashwin.sathya@outlook.com) wrote:

Hi,

If I provide a direct query\_string query as "foo bar" ( without the quotes), it gets treated as "foo" OR "bar". Is it possible to change this default behavior. I want it to be defaulted to "foo" AND "bar".

Looking up at Lucene, it looks like it is configured by,

[https://lucene.apache.org/core/4\_1\_0/queryparser/org/apache/lucene/queryparser/classic/QueryParserBase.html#setDefaultOperator(org.apache.lucene.queryparser.classic.QueryParser.Operator)](https://lucene.apache.org/core/4_1_0/queryparser/org/apache/lucene/queryparser/classic/QueryParserBase.html#setDefaultOperator%28org.apache.lucene.queryparser.classic.QueryParser.Operator%29)

Is there a way that I can configure it when running elastic search ??

--

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).

--  
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:15am UTC](https://discuss.elastic.co/t/query-string-query-and-default-operator/13729/4 "2017-07-06T02:15:04Z")

</div>


