# Elasticsearch painless access dynamically named field

**URL:** <https://discuss.elastic.co/t/elasticsearch-painless-access-dynamically-named-field/122025>\
**Category:** Elasticsearch\
**Created:** [March 1, 2018, 10:04am UTC](https://discuss.elastic.co/t/elasticsearch-painless-access-dynamically-named-field/122025 "2018-03-01T10:04:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jibin\_Mathews](https://avatars.discourse-cdn.com/v4/letter/j/8e7dd6/32.png) [@Jibin\_Mathews](https://discuss.elastic.co/u/Jibin_Mathews)\
**Post date:** [March 1, 2018, 10:04am UTC](https://discuss.elastic.co/t/elasticsearch-painless-access-dynamically-named-field/122025/1 "2018-03-01T10:04:07Z")

</div>

I am trying to average a field in elastic search,

```
"aggs": {
      "avg_timedifference": {
         "avg": {
            "script" : "doc['@timestamp'].value"
         }
      }

```

this works,

where the mapping is,

```
    {
            "_index" : "justchill",
            "_type" : "doc",
            "_id" : "cRP1bWEB6Z3gZHtPaXv1",
            "_score" : 1.0,
            "_source" : {

              "port" : 80,
              "bing.sss-ccc.tc.DOWNSTREAM_dropped.bong" : 33.0,
              "@timestamp" : "2018-02-07T01:50:55.000Z",
              "message" : "ccc.dna-ccc.tc.DOWNSTREAM_dropped.kkk 33 1517968255",
              "@version" : "1",
              "host" : "localhost"
            }
          },
          {
            "_index" : "justchill",
            "_type" : "doc",
            "_id" : "cRP1bWEB6Z3gZHtPaXv1",
            "_score" : 1.0,
            "_source" : {

              "port" : 80,
              "bong.sss-ccc.tc.DOWNSTREAM_dropped.bing" : 33.0,
              "@timestamp" : "2018-02-07T01:50:55.000Z",
              "message" : "ccc.dna-ccc.tc.DOWNSTREAM_dropped.kkk 33 1517968255",
              "@version" : "1",
              "host" : "localhost"
            }
          },

```

what i want to do is access the fields here temporarly named bing..bong and bong ..bing .The field is dynamically mapped , any way to access the same?

---

<div class="post-metadata">

**Author:** ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)\
**Post date:** [March 1, 2018, 8:16pm UTC](https://discuss.elastic.co/t/elasticsearch-painless-access-dynamically-named-field/122025/2 "2018-03-01T20:16:07Z")

</div>

You need to know the full know of the field, there is no way to use a wildcard or anything like that. You could theoretically store this field name in another field using ingest, but that would require a second docvalues lookup at search time.

---

<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 29, 2018, 8:16pm UTC](https://discuss.elastic.co/t/elasticsearch-painless-access-dynamically-named-field/122025/3 "2018-03-29T20:16:09Z")

</div>

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