# Query / filter

**URL:** <https://discuss.elastic.co/t/query-filter/57086>\
**Category:** Elasticsearch\
**Created:** [August 3, 2016, 9:54am UTC](https://discuss.elastic.co/t/query-filter/57086 "2016-08-03T09:54:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![zen.xen](https://avatars.discourse-cdn.com/v4/letter/z/e495f1/32.png) [@zen.xen](https://discuss.elastic.co/u/zen.xen)\
**Post date:** [August 3, 2016, 9:54am UTC](https://discuss.elastic.co/t/query-filter/57086/1 "2016-08-03T09:54:03Z")

</div>

Hello,  
I have a little problem, I don't know how to write query type "or", I want to search 2 printers:  
filter looks like this:

```
{
  "query": {
    "match": {
      "message": {
        "query": "Aficio MP",
        "type": "phrase"
      }
    }
  }
}

```

I want to add other one, eg. RICOH MP, how should I do that?

---

<div class="post-metadata">

**Author:** ![shaunak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shaunak/32/6643_2.png) [@shaunak](https://discuss.elastic.co/u/shaunak)\
**Post date:** [August 3, 2016, 1:49pm UTC](https://discuss.elastic.co/t/query-filter/57086/2 "2016-08-03T13:49:34Z")

</div>

_As this is more of an Elasticsearch question, I'm moving this post to the Elasticsearch category. If you have a follow up Kibana question, feel free to move the post back to the Kibana category._

You will want to use the `bool` query, with `should`. You can read more about it here: [https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html).

---

<div class="post-metadata">

**Author:** ![zen.xen](https://avatars.discourse-cdn.com/v4/letter/z/e495f1/32.png) [@zen.xen](https://discuss.elastic.co/u/zen.xen)\
**Post date:** [August 3, 2016, 2:57pm UTC](https://discuss.elastic.co/t/query-filter/57086/3 "2016-08-03T14:57:30Z")

</div>

according your link I did something like this but it doesn't work, could you correct this?

```
{
  "bool": {
    "should": [
        {"query": "Aficio MP"},
        {"query": "RICOH MP"}
        ],
  }
}
```

---

<div class="post-metadata">

**Author:** ![shaunak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shaunak/32/6643_2.png) [@shaunak](https://discuss.elastic.co/u/shaunak)\
**Post date:** [August 3, 2016, 9:43pm UTC](https://discuss.elastic.co/t/query-filter/57086/4 "2016-08-03T21:43:10Z")

</div>

Try this instead:

```
{
  "query": {
    "bool": {
      "should": [
        {
          "match": {
            "message": {
              "query": "Aficio MP",
              "type": "phrase"
            }
          }
        },
        {
          "match": {
            "message": {
              "query": "RICOH MP",
              "type": "phrase"
            }
          }
        }
      ]
    }
  }
}

```

By the way there is a `match_phrase` query type that would shorten your query a bit:

```
{
  "query": {
    "bool": {
      "should": [
        {
          "match_phrase": {
            "message": "Aficio MP"
          }
        },
        {
          "match_phrase": {
            "message": "RICOH MP"
          }
        }
      ]
    }
  }
}
```

---

<div class="post-metadata">

**Author:** ![zen.xen](https://avatars.discourse-cdn.com/v4/letter/z/e495f1/32.png) [@zen.xen](https://discuss.elastic.co/u/zen.xen)\
**Post date:** [August 4, 2016, 5:41am UTC](https://discuss.elastic.co/t/query-filter/57086/5 "2016-08-04T05:41:44Z")

</div>

Thank you for your help, it works and now I understand how to create other queries.

---

<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 5, 2017, 10:30pm UTC](https://discuss.elastic.co/t/query-filter/57086/6 "2017-07-05T22:30:15Z")

</div>


