# Tagging fields instead of adding new fields

**URL:** <https://discuss.elastic.co/t/tagging-fields-instead-of-adding-new-fields/125475>\
**Category:** Elasticsearch\
**Created:** [March 25, 2018, 9:38am UTC](https://discuss.elastic.co/t/tagging-fields-instead-of-adding-new-fields/125475 "2018-03-25T09:38:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![yishain11](https://avatars.discourse-cdn.com/v4/letter/y/df705f/32.png) [@yishain11](https://discuss.elastic.co/u/yishain11)\
**Post date:** [March 25, 2018, 9:38am UTC](https://discuss.elastic.co/t/tagging-fields-instead-of-adding-new-fields/125475/1 "2018-03-25T09:38:37Z")

</div>

Hi everyone!  
I have a file with an array of objects, that host information about different fields - what is there value, have this value changed, etc.  
For example:

```
"changedFieldsList": [
    {
      "fieldId": "PK_NEWJOURNAL",
      "fieldType": "NUMBER",
      "fieldValue": "NULL",
      "fieldChanged": "Y"
    },
    {
      "fieldId": "OFFICE",
      "fieldType": "CHAR",
      "fieldValue": "NULL",
      "fieldChanged": "Y"
    },
    {
      "fieldId": "UPDATE_DATE",
      "fieldType": "DATE",
      "fieldValue": "2017-12-07 05:09:54+03:000",
      "fieldChanged": "Y"
    },
...

```

The problem is that this structure is making aggregation problems because the names of the fields are the same.

If I want to flat the file in order to have unique field names, is there a way to tag a specific field and add metadata to a field so I still can tell if the field have changed or any other useful metadata, without adding new fields?

---

<div class="post-metadata">

**Author:** ![yishain11](https://avatars.discourse-cdn.com/v4/letter/y/df705f/32.png) [@yishain11](https://discuss.elastic.co/u/yishain11)\
**Post date:** [March 27, 2018, 6:13am UTC](https://discuss.elastic.co/t/tagging-fields-instead-of-adding-new-fields/125475/2 "2018-03-27T06:13:23Z")

</div>

Anyone?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 27, 2018, 6:34am UTC](https://discuss.elastic.co/t/tagging-fields-instead-of-adding-new-fields/125475/3 "2018-03-27T06:34:07Z")

</div>

Depending on what kind of aggs you want to run, you should better change completely the document (if the number of fields is under 1000).

For example you can't run a date histogram on the text field which represents a date. But if you transform your document you can.

I don't think I understood your proposal though which makes me think that what you proposed is not possible.

---

<div class="post-metadata">

**Author:** ![yishain11](https://avatars.discourse-cdn.com/v4/letter/y/df705f/32.png) [@yishain11](https://discuss.elastic.co/u/yishain11)\
**Post date:** [March 27, 2018, 7:14am UTC](https://discuss.elastic.co/t/tagging-fields-instead-of-adding-new-fields/125475/4 "2018-03-27T07:14:39Z")

</div>

Hi, thanks for the answer.  
What I mean is I want to know if a certain field has changed.  
Is there a way to tag a field as changed (the same way I tag a document when a condition is met) without adding a new field to the document?

---

<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:** [April 24, 2018, 7:14am UTC](https://discuss.elastic.co/t/tagging-fields-instead-of-adding-new-fields/125475/5 "2018-04-24T07:14:45Z")

</div>

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