# Illegal\_argument\_exception

**URL:** <https://discuss.elastic.co/t/illegal-argument-exception/290743>\
**Category:** Elasticsearch\
**Created:** [December 2, 2021, 9:45am UTC](https://discuss.elastic.co/t/illegal-argument-exception/290743 "2021-12-02T09:45:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cyberzlo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cyberzlo/32/65490_2.png) [@cyberzlo](https://discuss.elastic.co/u/cyberzlo)\
**Post date:** [December 2, 2021, 9:45am UTC](https://discuss.elastic.co/t/illegal-argument-exception/290743/1 "2021-12-02T09:45:40Z")

</div>

Hi, I have problem with elastic error `illegal_argument_exception` because I changed field from text to number. However only new indexes have number field, old still have text field - I guess.

```auto
"type": "illegal_argument_exception", "reason": "Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true on [XXX] in order to load field data by uninverting the inverted index. Note that this can use significant memory."

```

How can I fix it? Do I need reindex all? If yes, how? I have few daily indexes.

Thanks

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [December 6, 2021, 2:05am UTC](https://discuss.elastic.co/t/illegal-argument-exception/290743/2 "2021-12-06T02:05:39Z")

</div>

A reindex for your older data is the best approach.

[Reindex API | Elasticsearch Guide [7.15] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html) is the best place to start 🙂

---

<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:** [January 3, 2022, 2:05am UTC](https://discuss.elastic.co/t/illegal-argument-exception/290743/3 "2022-01-03T02:05:55Z")

</div>

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