# Elasticsearch Query: using match query with AND operator, fetching all the data

**URL:** <https://discuss.elastic.co/t/elasticsearch-query-using-match-query-with-and-operator-fetching-all-the-data/353724>\
**Category:** Elasticsearch\
**Created:** [February 20, 2024, 8:20pm UTC](https://discuss.elastic.co/t/elasticsearch-query-using-match-query-with-and-operator-fetching-all-the-data/353724 "2024-02-20T20:20:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mohan\_T](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@Mohan\_T](https://discuss.elastic.co/u/Mohan_T)\
**Post date:** [February 20, 2024, 8:20pm UTC](https://discuss.elastic.co/t/elasticsearch-query-using-match-query-with-and-operator-fetching-all-the-data/353724/1 "2024-02-20T20:20:52Z")

</div>

**Query**

```auto
{
    "query": {
        "bool": {
            "should": [
                
                {
                    "match": {
                        "keywords.keyword_values": {
                            "query": "prayer room",
                            "operator": "AND"
                        }
                    }
                }
            ],
            "minimum_should_match": "1"
        }
    }
}

```

**Doc 1**

```auto
"keywords": [
  {
    "keyword_values": "room"
  },
  {
    "keyword_values": "prayer"
  }
}

```

**Doc 2**

```auto
"keywords": [
  {
    "keyword_values": "room prayer"
  }
}

```

**Doc 3**

```auto
"keywords": [
  {
    "keyword_values": "prayer room"
  }
}

```

I want to fetch only **Doc 2 & Doc 3** not Doc 1, the above query is fetching all 3 Docs

---

<div class="post-metadata">

**Author:** ![RabBit\_BR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rabbit_br/32/82261_2.png) [@RabBit\_BR](https://discuss.elastic.co/u/RabBit_BR)\
**Post date:** [February 20, 2024, 8:27pm UTC](https://discuss.elastic.co/t/elasticsearch-query-using-match-query-with-and-operator-fetching-all-the-data/353724/2 "2024-02-20T20:27:53Z")

</div>

Please do not duplicate questions.

> [@Elasticsaerch Query Exact match](https://discuss.elastic.co/t/elasticsaerch-query-exact-match/353696):
>
> to find the exact match mappings "keywords": { "type": "object", "enabled": True, "properties": { "keyword\_values": { "type": "text", "analyzer": "synonym\_stemmer\_bad\_words\_analyzer", "fields": { "keyword": { "type": "keyword" } } } } } Doc 1 "keywords": [ { "keyword\_values": "marbles" }, { "keyword\_values": "flooring" } } Doc 2 …

> [@Elasticsaerch Query with exact match with stemmer apply](https://discuss.elastic.co/t/elasticsaerch-query-with-exact-match-with-stemmer-apply/353675):
>
> To fetch the exact match I have applied Ex: keywords.keyword\_values.keyword mappings: "keywords": { "type": "object", "enabled": True, "properties": { "keyword\_values": { "type": "text", "analyzer": "synonym\_stemmer\_bad\_words\_analyzer", "fields": { "keyword": { "type": "keyword" } } } } } keywords.keyword\_values.keyword exact match if am applying, stemmer is not…

---

<div class="post-metadata">

**Author:** ![Mohan\_T](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@Mohan\_T](https://discuss.elastic.co/u/Mohan_T)\
**Post date:** [February 20, 2024, 8:32pm UTC](https://discuss.elastic.co/t/elasticsearch-query-using-match-query-with-and-operator-fetching-all-the-data/353724/3 "2024-02-20T20:32:03Z")

</div>

I have updated the question

---

<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:** [March 19, 2024, 8:32pm UTC](https://discuss.elastic.co/t/elasticsearch-query-using-match-query-with-and-operator-fetching-all-the-data/353724/4 "2024-03-19T20:32:22Z")

</div>

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