Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elasticsearch enum field

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.

like image 219
eran Avatar asked May 23 '13 11:05

eran


1 Answers

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.

like image 146
DrTech Avatar answered Sep 26 '22 04:09

DrTech