# How to Implement Flexible Value Filters for a Field in Elastic App Search?

**URL:** <https://discuss.elastic.co/t/how-to-implement-flexible-value-filters-for-a-field-in-elastic-app-search/351291>\
**Category:** Elastic Search\
**Tags:** elastic-app-search\
**Created:** [January 17, 2024, 3:22pm UTC](https://discuss.elastic.co/t/how-to-implement-flexible-value-filters-for-a-field-in-elastic-app-search/351291 "2024-01-17T15:22:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chenko](https://avatars.discourse-cdn.com/v4/letter/c/258eb7/32.png) [@Chenko](https://discuss.elastic.co/u/Chenko)\
**Post date:** [January 17, 2024, 3:22pm UTC](https://discuss.elastic.co/t/how-to-implement-flexible-value-filters-for-a-field-in-elastic-app-search/351291/1 "2024-01-17T15:22:13Z")

</div>

Hello,

We're currently facing a challenge with a client who requires a filter for their App Search search query.

We've already consulted the Elastic [documentation](https://www.elastic.co/guide/en/app-search/current/filters.html#filters-value-filters) and have implemented a value filter. However, our issue lies in the specificity of the value filter, which doesn't align with our use case.

In our scenario:

We have a field named `available_languages`.

This field can contain values like `fr:de:en` or potentially `nl:de` and various other combinations.

Our goal is to apply a value filter to the `available_languages` field using a specific value, for instance, `fr` However, the current setup only works when there's an exact match with `fr` in the `available_languages` field, rather than matching all values like `fr:en…`

Is there a way to achieve this flexibility in the value filter or with another filter?

---

<div class="post-metadata">

**Author:** ![Kathleen\_DeRusso](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kathleen_derusso/32/132039_2.png) [@Kathleen\_DeRusso](https://discuss.elastic.co/u/Kathleen_DeRusso)\
**Post date:** [January 17, 2024, 6:56pm UTC](https://discuss.elastic.co/t/how-to-implement-flexible-value-filters-for-a-field-in-elastic-app-search/351291/2 "2024-01-17T18:56:40Z")

</div>

Hi there @Chenko - I think the easiest solution here would be to reformulate your data if possible to index the available languages as an array rather than as a delimited string.

So instead of indexing `available_languages` as `fr:de:en` you would index something that looked like this:

```auto
PUT /my-stuff/_doc/1
{
  "available_languages": ["fr", "de", "en"]
}

```

Then the filter query will work as expected:

```auto
curl -X POST '<your host>/api/as/v1/engines/<your engine name>/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-<your key>' \
-d '{
  "query": "...",
  "filters" : {
    "available_languages": ["fr"]
  }
}'

```

---

<div class="post-metadata">

**Author:** ![Chenko](https://avatars.discourse-cdn.com/v4/letter/c/258eb7/32.png) [@Chenko](https://discuss.elastic.co/u/Chenko)\
**Post date:** [January 18, 2024, 8:59am UTC](https://discuss.elastic.co/t/how-to-implement-flexible-value-filters-for-a-field-in-elastic-app-search/351291/3 "2024-01-18T08:59:44Z")

</div>

Hi, Thanks for your reply.  
That would be the easiest indeed, thanks!

---

<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:** [February 15, 2024, 8:59am UTC](https://discuss.elastic.co/t/how-to-implement-flexible-value-filters-for-a-field-in-elastic-app-search/351291/4 "2024-02-15T08:59:55Z")

</div>

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