mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-09 06:25:07 +00:00
Merge pull request #12214 from martijnvg/percolator/_parent_field/npe
Fix NPE when percolating a document that has a _parent field configured in its mapping
This commit is contained in:
commit
44275f3e3e
@ -249,8 +249,10 @@ public class ParentFieldMapper extends MetadataFieldMapper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postParse(ParseContext context) throws IOException {
|
public void postParse(ParseContext context) throws IOException {
|
||||||
|
if (context.sourceToParse().flyweight() == false) {
|
||||||
parse(context);
|
parse(context);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void parseCreateField(ParseContext context, List<Field> fields) throws IOException {
|
protected void parseCreateField(ParseContext context, List<Field> fields) throws IOException {
|
||||||
|
@ -2054,7 +2054,7 @@ public class PercolatorTests extends ElasticsearchIntegrationTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParentChild() throws Exception {
|
public void testParentChild() throws Exception {
|
||||||
// We don't fail p/c queries, but those queries are unsuable because only one document can be provided in
|
// We don't fail p/c queries, but those queries are unusable because only a single document can be provided in
|
||||||
// the percolate api
|
// the percolate api
|
||||||
|
|
||||||
assertAcked(prepareCreate("index").addMapping("child", "_parent", "type=parent").addMapping("parent"));
|
assertAcked(prepareCreate("index").addMapping("child", "_parent", "type=parent").addMapping("parent"));
|
||||||
@ -2063,5 +2063,21 @@ public class PercolatorTests extends ElasticsearchIntegrationTest {
|
|||||||
.execute().actionGet();
|
.execute().actionGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPercolateDocumentWithParentField() throws Exception {
|
||||||
|
assertAcked(prepareCreate("index").addMapping("child", "_parent", "type=parent").addMapping("parent"));
|
||||||
|
client().prepareIndex("index", PercolatorService.TYPE_NAME, "1")
|
||||||
|
.setSource(jsonBuilder().startObject().field("query", matchAllQuery()).endObject())
|
||||||
|
.execute().actionGet();
|
||||||
|
|
||||||
|
// Just percolating a document that has a _parent field in its mapping should just work:
|
||||||
|
PercolateResponse response = client().preparePercolate()
|
||||||
|
.setDocumentType("parent")
|
||||||
|
.setPercolateDoc(new PercolateSourceBuilder.DocBuilder().setDoc("field", "value"))
|
||||||
|
.get();
|
||||||
|
assertMatchCount(response, 1);
|
||||||
|
assertThat(response.getMatches()[0].getId().string(), equalTo("1"));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user