fix bug in parent handling where the parsed parent value was not set in the SourceToParse

This commit is contained in:
Benjamin Devèze 2011-09-02 12:07:03 +02:00 committed by Shay Banon
parent 847b10dc99
commit 8958e9fd4a
2 changed files with 4 additions and 1 deletions

View File

@ -122,6 +122,7 @@ public class ParentFieldMapper extends AbstractFieldMapper<Uid> implements Inter
if (context.parser().currentName() != null && context.parser().currentName().equals(Defaults.NAME)) {
// we are in the parsing of _parent phase
String parentId = context.parser().text();
context.sourceToParse().parent(parentId);
return new Field(names.indexName(), Uid.createUid(context.stringBuilder(), type, parentId), store, index);
}
// otherwise, we are running it post processing of the xcontent

View File

@ -48,6 +48,7 @@ public class ParentMappingTests {
.copiedBytes()).type("type").id("1"));
// no _parent mapping, used as a simple field
assertThat(doc.parent(), equalTo(null));
assertThat(doc.rootDoc().get("_parent"), equalTo("1122"));
}
@ -64,6 +65,7 @@ public class ParentMappingTests {
.endObject()
.copiedBytes()).type("type").id("1"));
assertThat(doc.parent(), equalTo("1122"));
assertThat(doc.rootDoc().get("_parent"), equalTo(Uid.createUid("p_type", "1122")));
}