Say I have a field that can only have a finite set of values. Would it not be more efficient (index-wise, and/or storage-wise) to store it as some kind of ENUM?
Is there some such possibility in elasticsearch?
An example would be the names of the states in a state machine.
Yes it would. When you index full text fields, Elasticsearch also indexes information like the length of the field, and the position and frequency of each term in the field.
These are irrelevant to ENUM values, and can be excluded completely.
In fact, if you map your field as {"index": "not_analyzed"}
then, besides storing the exact value that you provide without trying to analyze it, it also disables storage of the extra info that I mentioned above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With