The default _parent field should not try to load global ordinals (#25851)

The default _parent field tries to load global ordinals because it is created with eager_global_ordinals=true.
This leads to an IllegalStateException because this field does not have doc_values.
This change explicitely sets eager_global_ordinals to false in order to avoid the ISE on startup.

Fixes #25849
This commit is contained in:
Jim Ferenczi 2017-07-24 13:07:19 +02:00 committed by GitHub
parent 0a4b38b60c
commit 93b04fb7bd
2 changed files with 5 additions and 1 deletions

View File

@ -65,7 +65,7 @@ public class ParentFieldMapper extends MetadataFieldMapper {
FIELD_TYPE.setIndexOptions(IndexOptions.NONE); FIELD_TYPE.setIndexOptions(IndexOptions.NONE);
FIELD_TYPE.setHasDocValues(true); FIELD_TYPE.setHasDocValues(true);
FIELD_TYPE.setDocValuesType(DocValuesType.SORTED); FIELD_TYPE.setDocValuesType(DocValuesType.SORTED);
FIELD_TYPE.setEagerGlobalOrdinals(true); FIELD_TYPE.setEagerGlobalOrdinals(false);
FIELD_TYPE.freeze(); FIELD_TYPE.freeze();
} }
} }
@ -78,6 +78,8 @@ public class ParentFieldMapper extends MetadataFieldMapper {
public Builder(String documentType) { public Builder(String documentType) {
super(Defaults.NAME, new ParentFieldType(Defaults.FIELD_TYPE, documentType), Defaults.FIELD_TYPE); super(Defaults.NAME, new ParentFieldType(Defaults.FIELD_TYPE, documentType), Defaults.FIELD_TYPE);
// Defaults to true
eagerGlobalOrdinals(true);
this.documentType = documentType; this.documentType = documentType;
builder = this; builder = this;
} }

View File

@ -124,6 +124,8 @@ public class ParentFieldMapperTests extends ESSingleNodeTestCase {
Set<String> allFields = new HashSet<>(mapperService.simpleMatchToIndexNames("*")); Set<String> allFields = new HashSet<>(mapperService.simpleMatchToIndexNames("*"));
assertTrue(allFields.contains("_parent")); assertTrue(allFields.contains("_parent"));
assertFalse(allFields.contains("_parent#null")); assertFalse(allFields.contains("_parent#null"));
MappedFieldType fieldType = mapperService.fullName("_parent");
assertFalse(fieldType.eagerGlobalOrdinals());
} }
private static int getNumberOfFieldWithParentPrefix(ParseContext.Document doc) { private static int getNumberOfFieldWithParentPrefix(ParseContext.Document doc) {