# Field has been missed in aggregate

**URL:** <https://discuss.elastic.co/t/field-has-been-missed-in-aggregate/244595>\
**Category:** Kibana\
**Created:** [August 11, 2020, 4:16pm UTC](https://discuss.elastic.co/t/field-has-been-missed-in-aggregate/244595 "2020-08-11T16:16:55Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![sahere37](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@sahere37](https://discuss.elastic.co/u/sahere37)\
**Post date:** [August 11, 2020, 4:16pm UTC](https://discuss.elastic.co/t/field-has-been-missed-in-aggregate/244595/1 "2020-08-11T16:16:55Z")

</div>

Hi all,  
I am trying to build a data table visualize so that show sum of my field named as "amount". for this purpose, i am trying to use sum aggregation in the metric part but i cannot find my field in the "field" part. it is noted that there are two "amount" fields as "amount" and "amount.keyword" that type of them are string. amount.keyword field is as following which it seems is aggregatable:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/1/3/13d72cd80b8ee0c52666d9999c97781770c61e7a.png)

amount field is as following which it seems it is not aggregatable:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/4/1/41925e1177a13ad0cf2a705fafcdba70a4bae468.png)  
I cannot see neither "amount" nor "amount.keyword" in aggregation of visualize. how can i handle this issue? any advise will be so appreciated. Regards

---

<div class="post-metadata">

**Author:** ![flash1293](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flash1293/32/41227_2.png) [@flash1293](https://discuss.elastic.co/u/flash1293)\
**Post date:** [August 12, 2020, 9:54am UTC](https://discuss.elastic.co/t/field-has-been-missed-in-aggregate/244595/2 "2020-08-12T09:54:28Z")

</div>

having a `.keyword` variant of a field is the default behavior of Elasticsearch: [Elasticsearch replaces string type with two new types text and keyword. | Elastic Blog](https://www.elastic.co/blog/strings-are-dead-long-live-strings)

They refer to the same data, they are just indexed in a different way. When you want to aggregate, `amount.keyword` is the right field to use - you can overwrite the shown name in the visualization.

> I cannot see neither "amount" nor "amount.keyword" in aggregation of visualize

What aggregation are you trying to use? A keyword field can be used with "Unique count", "Terms" and "Significant terms"

---

<div class="post-metadata">

**Author:** ![sahere37](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@sahere37](https://discuss.elastic.co/u/sahere37)\
**Post date:** [August 12, 2020, 9:58am UTC](https://discuss.elastic.co/t/field-has-been-missed-in-aggregate/244595/3 "2020-08-12T09:58:37Z")

</div>

many thanks for your reply. i want to use sum aggregation. how can i use amount.keyword for sum?

---

<div class="post-metadata">

**Author:** ![flash1293](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flash1293/32/41227_2.png) [@flash1293](https://discuss.elastic.co/u/flash1293)\
**Post date:** [August 12, 2020, 10:06am UTC](https://discuss.elastic.co/t/field-has-been-missed-in-aggregate/244595/4 "2020-08-12T10:06:10Z")

</div>

If `amount` is actually a number, then the mapping of your index in Elasticsearch is wrong - recreate your index with the right mapping (specifying `amount` is a number): [https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html#create-mapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html#create-mapping) , then reindex your existing data [https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html)

After that, recreate your index pattern in Kibana and the field will be recognized as number

---

<div class="post-metadata">

**Author:** ![sahere37](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@sahere37](https://discuss.elastic.co/u/sahere37)\
**Post date:** [August 12, 2020, 10:08am UTC](https://discuss.elastic.co/t/field-has-been-missed-in-aggregate/244595/5 "2020-08-12T10:08:41Z")

</div>

Many thanks. yes amount is number. does type of previous saved documents and also new ones of this field change?

---

<div class="post-metadata">

**Author:** ![flash1293](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flash1293/32/41227_2.png) [@flash1293](https://discuss.elastic.co/u/flash1293)\
**Post date:** [August 12, 2020, 10:10am UTC](https://discuss.elastic.co/t/field-has-been-missed-in-aggregate/244595/6 "2020-08-12T10:10:21Z")

</div>

You need to update existing documents by reindexing them into a new index with the correct mapping for the `amount` field. Check out the links I provided in my previous answer.

---

<div class="post-metadata">

**Author:** ![sahere37](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@sahere37](https://discuss.elastic.co/u/sahere37)\
**Post date:** [August 12, 2020, 10:52am UTC](https://discuss.elastic.co/t/field-has-been-missed-in-aggregate/244595/7 "2020-08-12T10:52:08Z")

</div>

many thanks for your reply. updating mapping faced with following message:

```
PUT /my_index/_mapping/reqres
{
    "properties": {
      

              "amount" : {
            
          "type": "long" 
    
    
            }
            }
      }

```

error message:

```
{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "mapper [amount] of different type, current_type [text], merged_type [long]"
      }
    ],
    "type": "illegal_argument_exception",
    "reason": "mapper [amount] of different type, current_type [text], merged_type [long]"
  },
  "status": 400
}
```

---

<div class="post-metadata">

**Author:** ![flash1293](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flash1293/32/41227_2.png) [@flash1293](https://discuss.elastic.co/u/flash1293)\
**Post date:** [August 12, 2020, 11:52am UTC](https://discuss.elastic.co/t/field-has-been-missed-in-aggregate/244595/8 "2020-08-12T11:52:36Z")

</div>

You need to create a new index for this, then use the re-index api to move data over.

---

<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:** [September 9, 2020, 11:52am UTC](https://discuss.elastic.co/t/field-has-been-missed-in-aggregate/244595/9 "2020-09-09T11:52:45Z")

</div>

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