# Multimatch with filter

**URL:** <https://discuss.elastic.co/t/multimatch-with-filter/206593>\
**Category:** Elasticsearch\
**Created:** [November 5, 2019, 11:10am UTC](https://discuss.elastic.co/t/multimatch-with-filter/206593 "2019-11-05T11:10:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rogermerz](https://avatars.discourse-cdn.com/v4/letter/r/e8c25b/32.png) [@rogermerz](https://discuss.elastic.co/u/rogermerz)\
**Post date:** [November 5, 2019, 11:10am UTC](https://discuss.elastic.co/t/multimatch-with-filter/206593/1 "2019-11-05T11:10:44Z")

</div>

Hey there  
I got product data with nested articles and the products got different types.  
Now I should search in the product.name and product.description and in the product.articles.gtin  
and should retrieve only products with the specified type.

Tried filtered multi\_match but got a parse error with that query:

GET products\_1\_en/\_search  
{  
"query": {  
"filtered" : {  
"query": {  
"multi\_match": {  
"query": "Bar grills",  
"fields": [  
"name",  
"description",  
"articles.gtin"  
],  
"type": "best\_fields"  
}  
},  
"filter": {  
"term": {  
"type": "ARTICLE\_PRODUCT"  
}  
}  
}  
}  
}

That one is working  
GET products\_1\_en/\_search  
{  
"query":{  
"multi\_match": {  
"query": "Bar grills",  
"fields": [  
"name",  
"description",  
"articles.gtin"  
],  
"type": "best\_fields"  
}  
}  
}

but there is no filter and if I search for a gtin number I retrieve no hits.

I there a possibility to do that?

{  
"properties":{  
"description":{  
"type":"text"  
},  
"id":{  
"type":"long"  
},  
"name":{  
"type":"text",  
"fields":{  
"keyword":{  
"type":"keyword",  
"ignore\_above":256  
}  
}  
},  
"type":{  
"type":"keyword"  
},  
"articles":{  
"type":"nested",  
"properties":{  
"description":{  
"type":"text",  
"fields":{  
"keyword":{  
"type":"keyword",  
"ignore\_above":256  
}  
}  
},  
"gtin":{  
"type":"keyword"  
},  
"id":{  
"type":"long"  
},  
"name":{  
"type":"text",  
"fields":{  
"keyword":{  
"type":"keyword",  
"ignore\_above":256  
}  
}  
},  
"productId":{  
"type":"long"  
},  
"uid":{  
"type":"keyword"  
}  
}  
}  
}  
}

Thanks for help.

---

<div class="post-metadata">

**Author:** ![abdon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abdon/32/9195_2.png) [@abdon](https://discuss.elastic.co/u/abdon)\
**Post date:** [November 7, 2019, 2:31pm UTC](https://discuss.elastic.co/t/multimatch-with-filter/206593/2 "2019-11-07T14:31:03Z")

</div>

The `filtered` query does not exist any more. Nowadays you have to use a `bool` query instead:

```auto
GET products_1_en/_search
{
  "query": {
    "bool": {
      "must": {
        "multi_match": {
          "query": "Bar grills",
          "fields": [
            "name",
            "description",
            "articles.gtin"
          ],
          "type": "best_fields"
        }
      },
      "filter": {
        "term": {
          "type": "ARTICLE_PRODUCT"
        }
      }
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![rogermerz](https://avatars.discourse-cdn.com/v4/letter/r/e8c25b/32.png) [@rogermerz](https://discuss.elastic.co/u/rogermerz)\
**Post date:** [November 8, 2019, 8:25am UTC](https://discuss.elastic.co/t/multimatch-with-filter/206593/3 "2019-11-08T08:25:23Z")

</div>

Thank you abdon  
that's it.

---

<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:** [December 6, 2019, 8:33am UTC](https://discuss.elastic.co/t/multimatch-with-filter/206593/4 "2019-12-06T08:33:47Z")

</div>

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