# Filter on sub object field, based on other fields value

**URL:** <https://discuss.elastic.co/t/filter-on-sub-object-field-based-on-other-fields-value/166743>\
**Category:** Elasticsearch\
**Created:** [February 1, 2019, 1:51pm UTC](https://discuss.elastic.co/t/filter-on-sub-object-field-based-on-other-fields-value/166743 "2019-02-01T13:51:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robert\_Baelde](https://avatars.discourse-cdn.com/v4/letter/r/b5ac83/32.png) [@Robert\_Baelde](https://discuss.elastic.co/u/Robert_Baelde)\
**Post date:** [February 1, 2019, 1:51pm UTC](https://discuss.elastic.co/t/filter-on-sub-object-field-based-on-other-fields-value/166743/1 "2019-02-01T13:51:56Z")

</div>

I have a document with two fields, one field is a string. the other a array:

```auto
{
    "foo": "bar",
    "faz": {
        "bar": "bla bla",
        "baz": "etc.. " 
    }
}

```

I want to be able to filter on `faz.bar`, but this is, dynamic on the value of `foo`. So if `foo: baz` i want to filter on `faz.baz`. Is there a query like `faz.{foo}` possible? How can i achieve the desired outcome?

---

<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 1, 2019, 1:51pm UTC](https://discuss.elastic.co/t/filter-on-sub-object-field-based-on-other-fields-value/166743/2 "2019-03-01T13:51:59Z")

</div>

Closed on March 1, 2019, 1:51pm UTC

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