# How to query multiple fileds in Kibana

**URL:** <https://discuss.elastic.co/t/how-to-query-multiple-fileds-in-kibana/306611>\
**Category:** Elasticsearch\
**Tags:** kql-kibana-query-language\
**Created:** [June 8, 2022, 12:34am UTC](https://discuss.elastic.co/t/how-to-query-multiple-fileds-in-kibana/306611 "2022-06-08T00:34:46Z")\
**Posts on this page:** 4\
**Page:** 2

<div class="post-metadata">

**Author:** ![dev9](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dev9/32/81258_2.png) [@dev9](https://discuss.elastic.co/u/dev9)\
**Post date:** [June 8, 2022, 7:35pm UTC](https://discuss.elastic.co/t/how-to-query-multiple-fileds-in-kibana/306611/21 "2022-06-08T19:35:43Z")

</div>

I just did change both servicename and servername to keyword then ran the query again without any luck. I keep getting correlationids that are not in the terms array

---

<div class="post-metadata">

**Author:** ![dev9](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dev9/32/81258_2.png) [@dev9](https://discuss.elastic.co/u/dev9)\
**Post date:** [June 8, 2022, 7:41pm UTC](https://discuss.elastic.co/t/how-to-query-multiple-fileds-in-kibana/306611/22 "2022-06-08T19:41:39Z")

</div>

> [@dev9](#):
>
> ```auto
> GET unity/_search
> {
> "query": {
> "bool": {
> "filter": [
> {
> "range": {
> "@timestamp": {
> "gte": "2020-04-01",
> "lte": "2022-07-01"
> }
> }
> }
> ], 
> "must": [
> {
> "match": {
> "serviceName": "Serviceworker"
> }
> }
> ],
> "should": [
> {
> "terms": {
> "correlationId": [
> "085178d5-e782-4ad9-a56a-5c08d906686d",
> "01b4ac00-1c67-4056-a571-455f9fd1c296"
> ]
>             
>             
> }
>           
> }
>         
>         
>         
> ],
> "minimum_should_match": 1
> }
>     
> }
>   
> }
> 
> ```

The query I ran after changing to keyword

```auto
GET unity/_search
{
  "query": {
    "bool": {
      "filter": [
        {
          "range": {
            "@timestamp": {
              "gte": "2020-04-01",
              "lte": "2022-07-01"
            }
          }
        }
      ], 
      "must": [
        {
          "match": {
            "serviceName": "Serviceworker"
          }
        }
      ],
      "should": [
        {
          "terms": {
            "correlationId": [
              "085178d5-e782-4ad9-a56a-5c08d906686d",
              "01b4ac00-1c67-4056-a571-455f9fd1c296"
            ]
            
            
          }
          
        }
        
        
        
      ],
      "minimum_should_match": 1
    }
    
  }
  
}

```

Result

```auto
{
  "took" : 835,
  "timed_out" : false,
  "_shards" : {
    "total" : 110,
    "successful" : 110,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 0,
      "relation" : "eq"
    },
    "max_score" : null,
    "hits" : []
  }
}

```

---

<div class="post-metadata">

**Author:** ![Tomo\_M](https://avatars.discourse-cdn.com/v4/letter/t/848f3c/32.png) [@Tomo\_M](https://discuss.elastic.co/u/Tomo_M)\
**Post date:** [June 9, 2022, 12:41am UTC](https://discuss.elastic.co/t/how-to-query-multiple-fileds-in-kibana/306611/23 "2022-06-09T00:41:10Z")

</div>

As I said before, please isolate the problem as far as you can. For example, try simple `match` query and `terms` query those included in boolean query to confirm both queries work well separetely. If one of them does not return the desired document, we can concentrate on that part.

---

<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 7, 2022, 12:41am UTC](https://discuss.elastic.co/t/how-to-query-multiple-fileds-in-kibana/306611/24 "2022-07-07T00:41:11Z")

</div>

Closed on July 7, 2022, 12:41am UTC

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

[Previous page](https://discuss.elastic.co/t/how-to-query-multiple-fileds-in-kibana/306611.md?page=1)
