# Default\_operator not working

**URL:** <https://discuss.elastic.co/t/default-operator-not-working/129872>\
**Category:** Elasticsearch\
**Created:** [April 27, 2018, 7:01pm UTC](https://discuss.elastic.co/t/default-operator-not-working/129872 "2018-04-27T19:01:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![tfe2012](https://avatars.discourse-cdn.com/v4/letter/t/49beb7/32.png) [@tfe2012](https://discuss.elastic.co/u/tfe2012)\
**Post date:** [April 27, 2018, 7:01pm UTC](https://discuss.elastic.co/t/default-operator-not-working/129872/1 "2018-04-27T19:01:34Z")

</div>

Hi, I try run:

> oracle AND san AND francisco AND hadoop

Get total of 1118 matches.

Then I try:

> oracle san francisco hadoop

I get total of 59 matches.

Query looks like:

[  
'query' =\> [  
'function\_score' =\> [  
'query' =\> [  
"bool" =\> [  
"must" =\> [  
'query\_string' =\> [  
'query' =\> $query, 'default\_operator' =\> 'AND'  
]  
],  
'filter' =\> [  
'range' =\> [  
'completeness' =\> [  
'from'=\>0.30, 'to'=\> 1.0  
]  
]  
]  
]  
],  
'field\_value\_factor' =\> [  
'field' =\> 'completeness'  
]  
]  
],

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 28, 2018, 10:34am UTC](https://discuss.elastic.co/t/default-operator-not-working/129872/2 "2018-04-28T10:34:37Z")

</div>

Could you provide a full recreation script as described in [About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

---

<div class="post-metadata">

**Author:** ![tfe2012](https://avatars.discourse-cdn.com/v4/letter/t/49beb7/32.png) [@tfe2012](https://discuss.elastic.co/u/tfe2012)\
**Post date:** [April 28, 2018, 11:15pm UTC](https://discuss.elastic.co/t/default-operator-not-working/129872/3 "2018-04-28T23:15:17Z")

</div>

total result: 8077

> {  
> "query": {  
> "query\_string": {  
> "default\_operator": "AND",  
> "query": "oracle AND san AND francisco AND hadoop"  
> }  
> }  
> }

total 331:

> {  
> "query": {  
> "query\_string": {  
> "default\_operator": "AND",  
> "query": "oracle san francisco hadoop"  
> }  
> }  
> }

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 30, 2018, 7:23am UTC](https://discuss.elastic.co/t/default-operator-not-working/129872/4 "2018-04-30T07:23:34Z")

</div>

This works well on my end.

BTW here is what a reproduction script is:

```auto
DELETE test 
PUT test 
POST test/_doc
{
  "text": "oracle san francisco hadoop"
}
POST test/_doc
{
  "text": "oracle"
}
POST test/_doc
{
  "text": "san francisco"
}
POST test/_doc
{
  "text": "hadoop"
}
GET test/_search
{
  "query": {
    "query_string": {
      "query": "oracle AND san AND francisco AND hadoop"
    }
  }
}
GET test/_search
{
  "query": {
    "query_string": {
      "default_operator": "AND", 
      "query": "oracle san francisco hadoop"
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![tfe2012](https://avatars.discourse-cdn.com/v4/letter/t/49beb7/32.png) [@tfe2012](https://discuss.elastic.co/u/tfe2012)\
**Post date:** [May 2, 2018, 9:42am UTC](https://discuss.elastic.co/t/default-operator-not-working/129872/5 "2018-05-02T09:42:40Z")

</div>

Maybe it work only with 1 field. I have about 10 different search fields.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 2, 2018, 9:55am UTC](https://discuss.elastic.co/t/default-operator-not-working/129872/6 "2018-05-02T09:55:07Z")

</div>

> Maybe it work only with 1 field. I have about 10 different search fields.

How can I know?

If you need help, please do what I asked at

> [@Default\_operator not working](https://discuss.elastic.co/t/default-operator-not-working/129872/2):
>
> Could you provide a full recreation script as described in [About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will help to better understand what you are doing. Please, try to keep the example as simple as possible. A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

---

<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:** [May 30, 2018, 9:55am UTC](https://discuss.elastic.co/t/default-operator-not-working/129872/7 "2018-05-30T09:55:17Z")

</div>

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