Why ES create duplicated field for single indexed and doc value field?

Hi All,

Recently, I am debugging ES 6.3 indexing flow through source code. I found that ES will new two objects for handling keyword type field. One is Field object for revert index store, and another one is SortedNumericDocValueField for handling doc value.

My question is that why ES create two fields? In my opinion, we could just create one Field object, and set FieldType with both indexed and doc value type options. In lucene level, it only just check field's type has these two options then handle them separately.

I also try to modify KeywordFieldMapper.java and this is my pseudocode:

Field field = new Field()

FieldType ft = new FieldType();
ft.setDimensions(2, 16);


And I saw Lucene could store this field correctly with doc values and revert index. Any one please help me?


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