# Wildcard field names in filter?

**URL:** <https://discuss.elastic.co/t/wildcard-field-names-in-filter/2720>\
**Category:** Elasticsearch\
**Created:** [June 15, 2015, 5:40pm UTC](https://discuss.elastic.co/t/wildcard-field-names-in-filter/2720 "2015-06-15T17:40:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jpblair](https://avatars.discourse-cdn.com/v4/letter/j/5e9695/32.png) [@jpblair](https://discuss.elastic.co/u/jpblair)\
**Post date:** [June 15, 2015, 5:40pm UTC](https://discuss.elastic.co/t/wildcard-field-names-in-filter/2720/1 "2015-06-15T17:40:11Z")

</div>

To provide an example, I have data that looks like this:

```
"example": {
    "abc": {
        "field1":"value1"
    },
    "def": {
        "field1":"value2"
    },
    "xyz": {
        "field1":"value3"
    }
}

```

I want to do a filter to return all documents where one of the objects nested in "example" has a "field1" of "value1". The complicating factor here is that the field names "abc," "def," and "xyz" are dynamic, so I can't do a term filter like "example.abc.field1 : value1", since I don't know the field name "abc". What I need is something like "example.\*.field1 : value1". Is this possible to do in Elasticsearch?

I've also been looking into the has\_child filter, but it appears that, unless I'm mistaken, this only works with arrays rather than objects. I know I could structure the field as an array and that would achieve the desired result, but that makes things difficult in the application layer since it requires me to iteratively search the array to find "example.xyz", which is not very scalable.

Thanks for your help!

---

<div class="post-metadata">

**Author:** ![Jason\_Wee](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@Jason\_Wee](https://discuss.elastic.co/u/Jason_Wee)\
**Post date:** [June 16, 2015, 12:23pm UTC](https://discuss.elastic.co/t/wildcard-field-names-in-filter/2720/2 "2015-06-16T12:23:31Z")

</div>

think so, for querystring, there is a wildcard field specifier [https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#\_multi\_field\_2](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#_multi_field_2)

hth

---

<div class="post-metadata">

**Author:** ![jpblair](https://avatars.discourse-cdn.com/v4/letter/j/5e9695/32.png) [@jpblair](https://discuss.elastic.co/u/jpblair)\
**Post date:** [July 9, 2015, 6:43pm UTC](https://discuss.elastic.co/t/wildcard-field-names-in-filter/2720/3 "2015-07-09T18:43:22Z")

</div>

Thanks for your response. That is correct, but I was looking for a filter that does this rather than a query. Either way I ended up deciding to go with a different approach.

---

<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:** [July 6, 2017, 12:02am UTC](https://discuss.elastic.co/t/wildcard-field-names-in-filter/2720/4 "2017-07-06T00:02:32Z")

</div>


