Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static FieldValueRetriever create(MapperService mapperService,

Collection<String> concreteFields = mapperService.simpleMatchToFullName(fieldPattern);
for (String field : concreteFields) {
if (fieldMappers.getMapper(field) != null) {
if (fieldMappers.getMapper(field) != null && mapperService.isMetadataField(field) == false) {
Set<String> sourcePath = mapperService.sourcePath(field);
fields.add(new FieldContext(field, sourcePath, format));
}
Expand All @@ -62,6 +62,7 @@ public static FieldValueRetriever create(MapperService mapperService,
return new FieldValueRetriever(fieldMappers, fields);
}


private FieldValueRetriever(DocumentFieldMappers fieldMappers,
List<FieldContext> fieldContexts) {
this.fieldMappers = fieldMappers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,29 @@ public void testNonExistentField() throws IOException {
assertThat(fields.size(), equalTo(0));
}

public void testMetadataFields() throws IOException {
MapperService mapperService = createMapperService();
XContentBuilder source = XContentFactory.jsonBuilder().startObject()
.field("field", "value")
.endObject();

Map<String, DocumentField> fields = retrieveFields(mapperService, source, "_routing");
assertTrue(fields.isEmpty());
}

public void testRetrieveAllFields() throws IOException {
MapperService mapperService = createMapperService();
XContentBuilder source = XContentFactory.jsonBuilder().startObject()
.field("field", "value")
.startObject("object")
.field("field", "other-value")
.endObject()
.endObject();

Map<String, DocumentField> fields = retrieveFields(mapperService, source, "*");
assertThat(fields.size(), equalTo(2));
}

public void testArrayValueMappers() throws IOException {
MapperService mapperService = createMapperService();

Expand Down