# Unable to search array values on filter

**URL:** <https://discuss.elastic.co/t/unable-to-search-array-values-on-filter/309196>\
**Category:** Elasticsearch\
**Created:** [July 8, 2022, 11:38am UTC](https://discuss.elastic.co/t/unable-to-search-array-values-on-filter/309196 "2022-07-08T11:38:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Himanshu\_Joshi1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/himanshu_joshi1/32/88015_2.png) [@Himanshu\_Joshi1](https://discuss.elastic.co/u/Himanshu_Joshi1)\
**Post date:** [July 8, 2022, 11:38am UTC](https://discuss.elastic.co/t/unable-to-search-array-values-on-filter/309196/1 "2022-07-08T11:38:04Z")

</div>

```auto
**This is my data**
{
  "took" : 2,
  "timed_out" : false,
  "_shards" : {
    "total" : 6,
    "successful" : 6,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 2,
      "relation" : "eq"
    },
    "max_score" : 2.5176964,
    "hits" : [
      {
        "_index" : "test",
        "_id" : "_3oifinsfi3m",
        "_score" : 2.5176964,
        "_source" : {
          "id" : "2839u423u4298",
          "title" : "Test",
          "body" : "Testing",
          "uniqueID" : "aaa",
        }
      },
      {
        "_index" : "test",
        "_id" : "fsufsifhi2uh2ui",
        "_score" : 2.5176964,
        "_source" : {
          "id" : "sfknjn2knan",
          "title" : "Test",
          "body" : "Testing123",
          "uniqueID" : "bbb"        
}
      }
    ]
  }
}

**This is my query :** 

GET _search
{
          "query": {
            "bool" : {
              "must" : {
                "multi_match" : { 
                  "query": "Test",
                  "fields" : ["title","body"] 
                }
              },
              "filter": {
                "terms" : { "uniqueID": ["aaa,vvv,bbb,ddd"] }
              }
            }
          }
}

**This is the output I'm getting :** 

{
  "took" : 2,
  "timed_out" : false,
  "_shards" : {
    "total" : 6,
    "successful" : 6,
    "skipped" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 0,
      "relation" : "eq"
    },
    "max_score" : null,
    "hits" : []
  }
}

The output is empty which should not be.

Can anybody help, i want to search a query for muliple fields and filter on one field which will be madatory the filtering on based of array values. I tried everything but not working.

```

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [July 8, 2022, 12:50pm UTC](https://discuss.elastic.co/t/unable-to-search-array-values-on-filter/309196/2 "2022-07-08T12:50:35Z")

</div>

Looks correct to me as you have listed a single large term with commas. What do you get if you instead run this?

```auto
GET _search
{
          "query": {
            "bool" : {
              "must" : {
                "multi_match" : { 
                  "query": "Test",
                  "fields" : ["title","body"] 
                }
              },
              "filter": {
                "terms" : { "uniqueID": ["aaa", "vvv", "bbb", "ddd"] }
              }
            }
          }
}

```

---

<div class="post-metadata">

**Author:** ![Himanshu\_Joshi1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/himanshu_joshi1/32/88015_2.png) [@Himanshu\_Joshi1](https://discuss.elastic.co/u/Himanshu_Joshi1)\
**Post date:** [July 8, 2022, 1:07pm UTC](https://discuss.elastic.co/t/unable-to-search-array-values-on-filter/309196/3 "2022-07-08T13:07:43Z")

</div>

@Christian_Dahlqvist

I'm getting empty result

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

```

---

<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:** [August 5, 2022, 1:07pm UTC](https://discuss.elastic.co/t/unable-to-search-array-values-on-filter/309196/4 "2022-08-05T13:07:48Z")

</div>

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