# Search in Array Field

**URL:** https://discuss.elastic.co/t/search-in-array-field/295732
**Category:** Elasticsearch
**Created:** [January 28, 2022, 8:36pm UTC](https://discuss.elastic.co/t/search-in-array-field/295732 "2022-01-28T20:36:11Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Sahil5](https://avatars.discourse-cdn.com/v4/letter/s/bb73d2/32.png) [@Sahil5](https://discuss.elastic.co/u/Sahil5)
#### Post date: [January 28, 2022, 8:36pm UTC](https://discuss.elastic.co/t/search-in-array-field/295732/1 "2022-01-28T20:36:11Z")

</div>

Hi Team,

I want to enable search on array field but only want to retrieve the value from an array that matches the search query.

**Example**  
Document 1 - [A,B]  
Document 2 - [A,C]

Below is the Query

```auto
{
  "query": {
    "bool": {
      "must": [
        {
          "query_string": {
            "query": "A",
            "fields": [
              "array"
            ]
          }
        }
      ]
    }
  }
}

```

Above Query is returning me below result  
Document 1 - [A,B]  
Document 2 - [A,C]

**Expected output**  
Document 1 - [A]  
Document 2 - [A]

Any suggestions?

---

<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: [February 25, 2022, 8:37pm UTC](https://discuss.elastic.co/t/search-in-array-field/295732/2 "2022-02-25T20:37:01Z")

</div>

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