Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enabling Elasticsearch _size field

I have an index with over 9,000,000 docs.

I have defined my own mapping and everything went fine.

The only problem is that I forgot to enable the _size field and now I need it to localize document with a large size.

From the documentation I found that it's just fine to use the PUT mapping API with these parameters:

{
    "my_index": {
        "_size": {
            "enabled": true
        }
    }
}
  • Does the new mapping will be merged with the one already set?
  • Does the size field will be enabled for already stored documents?

I am a little worried making changes to mapping beacuse the last time that I have updated the settings with a new analyzer the service was having problem due to shard relocation and everything got stuck.

like image 252
betto86 Avatar asked Dec 27 '25 18:12

betto86


1 Answers

The mappings will be merged OK and the _size field will be enabled for all your documents of type my_index.

Note that if you want to store the _size (in addition to just index its value), you also need to add "store": "yes" in your _size mapping.

Unfortunately, you'll need to re-index your data in order for the _size field to be properly indexed.

like image 157
Val Avatar answered Dec 30 '25 23:12

Val



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!