# How to retrieve documents that match all of the words?

**URL:** <https://discuss.elastic.co/t/how-to-retrieve-documents-that-match-all-of-the-words/218928>\
**Category:** Elasticsearch\
**Created:** [February 12, 2020, 9:07am UTC](https://discuss.elastic.co/t/how-to-retrieve-documents-that-match-all-of-the-words/218928 "2020-02-12T09:07:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhijith\_chandran](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abhijith_chandran/32/60470_2.png) [@abhijith\_chandran](https://discuss.elastic.co/u/abhijith_chandran)\
**Post date:** [February 12, 2020, 9:08am UTC](https://discuss.elastic.co/t/how-to-retrieve-documents-that-match-all-of-the-words/218928/1 "2020-02-12T09:08:00Z")

</div>

Hi, I am using the below DSL query:

```auto
{   
   "_source": [
        "title",
        "bench",
        "court",
        "id_",
        "verdict"
    ],
    "size": 10,
    "query": {
    	
        "bool": {
            "must": {
                
                    "multi_match": {
                    	"query": "I R coelho" 
                    ,
                    "fields": [
                        "title",
                        "content"
                    ]
                }
            },
        "filter": {
        	
        "term": {
          "verdict": "alllowed"
       }
        
        },
            "should": {
                "multi_match": {
                    "query": "I R coelho",
                    "fields": [
                        "title.standard^16",
                        "content.standard^2"
                    ]
                }
            }
            
        }
          
    
    },
    "highlight": 
    {
        "fields": {
            "title": {},
            "content": {}
        }
    }
}

```

But when I search for terms with multiple words like ` I R Coelho` it returns results that have `I R` in them but not `coelho`. How do I make it search that the top query is always the one that matches all the words in the query?

Here is my current mapping:

```auto
{
    "courts_test": {
        "mappings": {
            "properties": {
                "author": {
                    "type": "text",
                    "fields": {
                        "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                        }
                    }
                },
                "bench": {
                    "type": "text",
                    "fields": {
                        "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                        }
                    }
                },
                "citation": {
                    "type": "text",
                    "fields": {
                        "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                        }
                    }
                },
                "content": {
                    "type": "text",
                    "fields": {
                        "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                        }
                    }
                },
                "court": {
                    "type": "text",
                    "fields": {
                        "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                        }
                    }
                },
                "date": {
                    "type": "text",
                    "fields": {
                        "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                        }
                    }
                },
                "id_": {
                    "type": "text",
                    "fields": {
                        "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                        }
                    }
                },
                "title": {
                    "type": "text",
                    "fields": {
                        "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                        }
                    }
                },
                "verdict": {
                    "type": "text",
                    "fields": {
                        "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                        }
                    }
                }
            }
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 12, 2020, 9:17am UTC](https://discuss.elastic.co/t/how-to-retrieve-documents-that-match-all-of-the-words/218928/2 "2020-02-12T09:17:58Z")

</div>

Have a look at `operator`. [https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html#operator-min](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html#operator-min)

---

<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 11, 2020, 9:29am UTC](https://discuss.elastic.co/t/how-to-retrieve-documents-that-match-all-of-the-words/218928/3 "2020-03-11T09:29:11Z")

</div>

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