# Matching all the values from a multi-value field

**URL:** https://discuss.elastic.co/t/matching-all-the-values-from-a-multi-value-field/67246
**Category:** Elasticsearch
**Created:** [November 26, 2016, 7:36pm UTC](https://discuss.elastic.co/t/matching-all-the-values-from-a-multi-value-field/67246 "2016-11-26T19:36:52Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Bostjan\_Kovac](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bostjan_kovac/32/9671_2.png) [@Bostjan\_Kovac](https://discuss.elastic.co/u/Bostjan_Kovac)
#### Post date: [November 26, 2016, 7:36pm UTC](https://discuss.elastic.co/t/matching-all-the-values-from-a-multi-value-field/67246/1 "2016-11-26T19:36:52Z")

</div>

hi all!

I am trying to build query that will match a document only when all the document's values in it's multi-value field are present in the given query.

Example:

```
doc1.multiField: [A, B, C]
doc2.multiField: [A, B, C, D]
doc3.multiField: [A, B]

query.multiField: [A, B, C, E, F]

```

So my problem is when I query for values A,B,C, E and F in my index, I want only doc1 and doc3 in my search results, because their multiField values are all contained in my query. doc2 should not be matched, because D is not present in the query.

I am not even sure that this is possible in Elasticsearch. I've been through all the documentation and I would basically need some sort of condition where doc\*.multiField.length == doc\*.matchedCount or whatever.

minimum\_should\_match option does not cut it in my case, because it references the number of matching values from the query, whereas I need this condition on the document, which of course differs from document to document.

---

<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 24, 2016, 7:37pm UTC](https://discuss.elastic.co/t/matching-all-the-values-from-a-multi-value-field/67246/2 "2016-12-24T19:37:27Z")

</div>

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