when serializing mappers into json, also serialize index, type and id mappings (index for the enabled flag, and id/type for the store)
This commit is contained in:
parent
8223418b04
commit
f3cc8d1249
|
@ -228,6 +228,9 @@ public class XContentDocumentMapper implements DocumentMapper, ToXContent {
|
|||
|
||||
final List<FieldMapper> tempFieldMappers = newArrayList();
|
||||
// add the basic ones
|
||||
if (indexFieldMapper.enabled()) {
|
||||
tempFieldMappers.add(indexFieldMapper);
|
||||
}
|
||||
tempFieldMappers.add(typeFieldMapper);
|
||||
tempFieldMappers.add(sourceFieldMapper);
|
||||
tempFieldMappers.add(uidFieldMapper);
|
||||
|
@ -391,6 +394,9 @@ public class XContentDocumentMapper implements DocumentMapper, ToXContent {
|
|||
synchronized (mutex) {
|
||||
fieldMapperListeners.add(fieldMapperListener);
|
||||
if (includeExisting) {
|
||||
if (indexFieldMapper.enabled()) {
|
||||
fieldMapperListener.fieldMapper(indexFieldMapper);
|
||||
}
|
||||
fieldMapperListener.fieldMapper(sourceFieldMapper);
|
||||
fieldMapperListener.fieldMapper(typeFieldMapper);
|
||||
fieldMapperListener.fieldMapper(idFieldMapper);
|
||||
|
@ -427,6 +433,6 @@ public class XContentDocumentMapper implements DocumentMapper, ToXContent {
|
|||
}
|
||||
|
||||
@Override public void toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
rootObjectMapper.toXContent(builder, params, allFieldMapper, sourceFieldMapper);
|
||||
rootObjectMapper.toXContent(builder, params, indexFieldMapper, typeFieldMapper, idFieldMapper, allFieldMapper, sourceFieldMapper);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.index.mapper.xcontent.index;
|
|||
import org.apache.lucene.document.Field;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.index.mapper.IndexFieldMapper;
|
||||
import org.elasticsearch.index.mapper.ParsedDocument;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentMapperTests;
|
||||
|
@ -42,6 +43,7 @@ public class IndexTypeMapperTests {
|
|||
XContentDocumentMapper docMapper = XContentMapperTests.newParser().parse(mapping);
|
||||
assertThat(docMapper.indexMapper().enabled(), equalTo(true));
|
||||
assertThat(docMapper.indexMapper().store(), equalTo(Field.Store.YES));
|
||||
assertThat(docMapper.mappers().indexName("_index").mapper(), instanceOf(IndexFieldMapper.class));
|
||||
|
||||
ParsedDocument doc = docMapper.parse("type", "1", XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
|
|
Loading…
Reference in New Issue