# The default\_operator=AND not working with multi queries in elasticsearch

**URL:** <https://discuss.elastic.co/t/the-default-operator-and-not-working-with-multi-queries-in-elasticsearch/284151>\
**Category:** Elasticsearch\
**Created:** [September 14, 2021, 7:13am UTC](https://discuss.elastic.co/t/the-default-operator-and-not-working-with-multi-queries-in-elasticsearch/284151 "2021-09-14T07:13:34Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Drsaud](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drsaud/32/94000_2.png) [@Drsaud](https://discuss.elastic.co/u/Drsaud)\
**Post date:** [September 14, 2021, 7:13am UTC](https://discuss.elastic.co/t/the-default-operator-and-not-working-with-multi-queries-in-elasticsearch/284151/1 "2021-09-14T07:13:34Z")

</div>

I want to search for 2 queries in different fields using elasticsearch like this:

```auto
http://localhost:9200/ncar_index/ncar/_search?q=approvetool:مرسوم ملكي AND category:الأنظمة&size=100&sort=date:desc&default_operator=AND

```

but it act like its `OR` not `AND` it the result not exact

can you please help me

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [September 14, 2021, 7:54am UTC](https://discuss.elastic.co/t/the-default-operator-and-not-working-with-multi-queries-in-elasticsearch/284151/2 "2021-09-14T07:54:59Z")

</div>

Please start using the Query DSL. It seems that over the posts of the last weeks most of your issues come from not properly encoding HTTP parameters and thus probably cutting them off.

You can eliminate a whole problem domain by changing the way you are querying and it is also easier to debug - so I highly recommend you to do so (not for the first time 🙂)

---

<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:** [September 14, 2021, 7:55am UTC](https://discuss.elastic.co/t/the-default-operator-and-not-working-with-multi-queries-in-elasticsearch/284151/3 "2021-09-14T07:55:59Z")

</div>

I think there is a "space character" in `مرسوم ملكي` which probably translates the query to:

`approvetool:مرسوم` OR `ملكي` AND `category:الأنظمة`

My 2 cents

---

<div class="post-metadata">

**Author:** ![Drsaud](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drsaud/32/94000_2.png) [@Drsaud](https://discuss.elastic.co/u/Drsaud)\
**Post date:** [September 14, 2021, 7:58am UTC](https://discuss.elastic.co/t/the-default-operator-and-not-working-with-multi-queries-in-elasticsearch/284151/4 "2021-09-14T07:58:01Z")

</div>

You are right next project I will learn how it work with React.js and do so, but this one I need to finish it as fast as possible thank you for your advice and suggest

---

<div class="post-metadata">

**Author:** ![Drsaud](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drsaud/32/94000_2.png) [@Drsaud](https://discuss.elastic.co/u/Drsaud)\
**Post date:** [September 14, 2021, 8:01am UTC](https://discuss.elastic.co/t/the-default-operator-and-not-working-with-multi-queries-in-elasticsearch/284151/5 "2021-09-14T08:01:06Z")

</div>

Yes, the space is intended its like for example a royal letter

and there are other like General letter or minister litter , so it have to both exact

can I solve this?

---

<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:** [September 14, 2021, 8:51am UTC](https://discuss.elastic.co/t/the-default-operator-and-not-working-with-multi-queries-in-elasticsearch/284151/6 "2021-09-14T08:51:16Z")

</div>

May be try with `approvetool:"مرسوم ملكي" AND category:"الأن"`

---

<div class="post-metadata">

**Author:** ![Drsaud](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drsaud/32/94000_2.png) [@Drsaud](https://discuss.elastic.co/u/Drsaud)\
**Post date:** [September 14, 2021, 9:23am UTC](https://discuss.elastic.co/t/the-default-operator-and-not-working-with-multi-queries-in-elasticsearch/284151/7 "2021-09-14T09:23:15Z")

</div>

> [@dadoonet](#):
>
> approvetool:"مرسوم ملكي" AND category:"الأن"

Same problem

---

<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:** [September 14, 2021, 9:36am UTC](https://discuss.elastic.co/t/the-default-operator-and-not-working-with-multi-queries-in-elasticsearch/284151/8 "2021-09-14T09:36:16Z")

</div>

I have no idea then.

I'd use the query dsl instead of using the URL to pass the query.

If you don't succeed, 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 is something anyone can **copy and paste in Kibana dev console** , click on the run button to reproduce your use case. It 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:** ![Drsaud](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drsaud/32/94000_2.png) [@Drsaud](https://discuss.elastic.co/u/Drsaud)\
**Post date:** [September 15, 2021, 7:57am UTC](https://discuss.elastic.co/t/the-default-operator-and-not-working-with-multi-queries-in-elasticsearch/284151/9 "2021-09-15T07:57:34Z")

</div>

Okay thank you, I have quick question if possiable if I want to search for like letter but I have others like royal letter and general letter, can I search and get the result of only letter, becasue when I search I get all of them because all have letter term

---

<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:** [September 15, 2021, 8:52am UTC](https://discuss.elastic.co/t/the-default-operator-and-not-working-with-multi-queries-in-elasticsearch/284151/10 "2021-09-15T08:52:06Z")

</div>

Please provide a full example.

---

<div class="post-metadata">

**Author:** ![Drsaud](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drsaud/32/94000_2.png) [@Drsaud](https://discuss.elastic.co/u/Drsaud)\
**Post date:** [September 15, 2021, 11:41am UTC](https://discuss.elastic.co/t/the-default-operator-and-not-working-with-multi-queries-in-elasticsearch/284151/11 "2021-09-15T11:41:37Z")

</div>

For example: if I want to search for this

`http://localhost:9200/ncar_index/ncar/_search?q=category:letter&size=100&sort=date:desc&default_operator=AND`

I will get in the result from three different category :

> letter, royal letter, general letter

because they all have

> letter

can I search for only exact letter without the other terms

---

<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:** [September 15, 2021, 12:06pm UTC](https://discuss.elastic.co/t/the-default-operator-and-not-working-with-multi-queries-in-elasticsearch/284151/13 "2021-09-15T12:06:04Z")

</div>

Use a `term` query instead. Or change the analyzer for this field to be a `keyword`.

---

<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:** [October 14, 2021, 7:21am UTC](https://discuss.elastic.co/t/the-default-operator-and-not-working-with-multi-queries-in-elasticsearch/284151/15 "2021-10-14T07:21:26Z")

</div>

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