# Filter array contains only

**URL:** <https://discuss.elastic.co/t/filter-array-contains-only/167593>\
**Category:** Elastic Search\
**Tags:** elastic-app-search\
**Created:** [February 8, 2019, 9:10am UTC](https://discuss.elastic.co/t/filter-array-contains-only/167593 "2019-02-08T09:10:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![steverob](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steverob/32/40672_2.png) [@steverob](https://discuss.elastic.co/u/steverob)\
**Post date:** [February 8, 2019, 9:10am UTC](https://discuss.elastic.co/t/filter-array-contains-only/167593/1 "2019-02-08T09:10:23Z")

</div>

Is it possible to use the Filter API to find documents with an array field that contains only the specified values?

Eg. I need to find documents with `{array_attr: ["A", "B", "C"]}`. I do not want documents that may have `{array_attr: ["A", "B", "C", "D"]}`

---

<div class="post-metadata">

**Author:** ![goodroot](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/goodroot/32/38389_2.png) [@goodroot](https://discuss.elastic.co/u/goodroot)\
**Post date:** [February 8, 2019, 5:03pm UTC](https://discuss.elastic.co/t/filter-array-contains-only/167593/2 "2019-02-08T17:03:46Z")

</div>

> [@steverob](#):
>
> Eg. I need to find documents with `{array_attr: ["A", "B", "C"]}` . I do not want documents that may have `{array_attr: ["A", "B", "C", "D"]}`

Hey Steve ~

Thanks for the post.

My first thought is: no, this isn't supported.

There is no way to clearly say: "I want documents with the ["A", "B", "C"] array but not the ["A, "B", "C", "D"] array.

As you likely read in the [filters documentation](https://swiftype.com/documentation/app-search/api/search/filters), we have clauses that you can apply to filters: ANY, ALL, NONE. The clauses work on individual values, which can be placed within an array, but not array values.

Can you please share some more details about your use case? We might be able to get creative.

Enjoy the day,

Kellen

---

<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 8, 2019, 5:04pm UTC](https://discuss.elastic.co/t/filter-array-contains-only/167593/3 "2019-03-08T17:04:03Z")

</div>

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