# Search for exact field in an array

**URL:** <https://discuss.elastic.co/t/search-for-exact-field-in-an-array/234931>\
**Category:** Elasticsearch\
**Created:** [May 29, 2020, 2:06pm UTC](https://discuss.elastic.co/t/search-for-exact-field-in-an-array/234931 "2020-05-29T14:06:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jawad](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jawad/32/69386_2.png) [@Jawad](https://discuss.elastic.co/u/Jawad)\
**Post date:** [May 29, 2020, 2:06pm UTC](https://discuss.elastic.co/t/search-for-exact-field-in-an-array/234931/1 "2020-05-29T14:06:18Z")

</div>

**Elasticsearch version: 7.1.1**

Hi, I try a lot but could not found any solution  
in my index, I have a field which is containing strings.

> so, for example, I have two documents containing different values in locations array.

Document-1:

```auto
"doc" : {
                "locations" : [
                  "Cloppenburg",
                  "Berlin"
                ]
              }

```

Document-2:

```auto
        "doc" : {
                "locations" : [
                  "Landkreis Cloppenburg",
                  "Berlin"
                ]
              }

```

a user requests a search for a term **Cloppenburg**  
and I want to return only those documents which contain term **Cloppenburg**  
and not **Landkreis Cloppenburg**.  
the results should contain only **Document-1**.

I am using the following query and getting both documents back.  
can someone please help me out in this.

```auto
    GET /my_index/_search
     {
        "query": {
            "bool": {
                "must": [
                    {
                        "match": {
                            "doc.locations": {
                                "query": "cloppenburg",
                                "operator": "and"
                            }
                        }
                    }
                ]
            }
        }
    }

```

---

<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:** [June 26, 2020, 2:06pm UTC](https://discuss.elastic.co/t/search-for-exact-field-in-an-array/234931/2 "2020-06-26T14:06:24Z")

</div>

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