fix bug in parent handling where the parsed parent value was not set in the SourceToParse
This commit is contained in:
parent
847b10dc99
commit
8958e9fd4a
|
@ -122,6 +122,7 @@ public class ParentFieldMapper extends AbstractFieldMapper<Uid> implements Inter
|
||||||
if (context.parser().currentName() != null && context.parser().currentName().equals(Defaults.NAME)) {
|
if (context.parser().currentName() != null && context.parser().currentName().equals(Defaults.NAME)) {
|
||||||
// we are in the parsing of _parent phase
|
// we are in the parsing of _parent phase
|
||||||
String parentId = context.parser().text();
|
String parentId = context.parser().text();
|
||||||
|
context.sourceToParse().parent(parentId);
|
||||||
return new Field(names.indexName(), Uid.createUid(context.stringBuilder(), type, parentId), store, index);
|
return new Field(names.indexName(), Uid.createUid(context.stringBuilder(), type, parentId), store, index);
|
||||||
}
|
}
|
||||||
// otherwise, we are running it post processing of the xcontent
|
// otherwise, we are running it post processing of the xcontent
|
||||||
|
|
|
@ -48,6 +48,7 @@ public class ParentMappingTests {
|
||||||
.copiedBytes()).type("type").id("1"));
|
.copiedBytes()).type("type").id("1"));
|
||||||
|
|
||||||
// no _parent mapping, used as a simple field
|
// no _parent mapping, used as a simple field
|
||||||
|
assertThat(doc.parent(), equalTo(null));
|
||||||
assertThat(doc.rootDoc().get("_parent"), equalTo("1122"));
|
assertThat(doc.rootDoc().get("_parent"), equalTo("1122"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,6 +65,7 @@ public class ParentMappingTests {
|
||||||
.endObject()
|
.endObject()
|
||||||
.copiedBytes()).type("type").id("1"));
|
.copiedBytes()).type("type").id("1"));
|
||||||
|
|
||||||
|
assertThat(doc.parent(), equalTo("1122"));
|
||||||
assertThat(doc.rootDoc().get("_parent"), equalTo(Uid.createUid("p_type", "1122")));
|
assertThat(doc.rootDoc().get("_parent"), equalTo(Uid.createUid("p_type", "1122")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue