From 68282dd9e9833fa16ce413f7bb46ea808ddb5598 Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Thu, 17 Mar 2016 14:58:57 +0100 Subject: [PATCH] parent/child: `parent_id` query should take the child type into account too. If this query doesn't take the child type into account then it can match other child document types pointing to the same parent type and that have the same id too. --- .../index/query/ParentIdQueryBuilder.java | 12 +++++++++++- .../index/query/ParentIdQueryBuilderTests.java | 15 ++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/index/query/ParentIdQueryBuilder.java b/core/src/main/java/org/elasticsearch/index/query/ParentIdQueryBuilder.java index f9bd7623f35..4a2efa95c9a 100644 --- a/core/src/main/java/org/elasticsearch/index/query/ParentIdQueryBuilder.java +++ b/core/src/main/java/org/elasticsearch/index/query/ParentIdQueryBuilder.java @@ -19,13 +19,18 @@ package org.elasticsearch.index.query; +import org.apache.lucene.index.Term; +import org.apache.lucene.search.BooleanClause; +import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.DocValuesTermsQuery; import org.apache.lucene.search.Query; +import org.apache.lucene.search.TermQuery; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.internal.ParentFieldMapper; +import org.elasticsearch.index.mapper.internal.TypeFieldMapper; import java.io.IOException; import java.util.Objects; @@ -71,7 +76,12 @@ public final class ParentIdQueryBuilder extends AbstractQueryBuilder