Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NPE bug inner_hits #50709

Merged
merged 1 commit into from
Jan 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ public TopDocsAndMaxScore[] topDocs(SearchHit[] hits) throws IOException {
.build();
} else {
String parentId = getSortedDocValue(parentIdFieldMapper.name(), context, hit.docId());
if (parentId == null) {
result[i] = new TopDocsAndMaxScore(Lucene.EMPTY_TOP_DOCS, Float.NaN);
continue;
}
q = context.mapperService().fullName(IdFieldMapper.NAME).termQuery(parentId, qsc);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
"Test two sub-queries with only one having inner_hits":
- skip:
version: " - 7.99.99"
reason: "The bug was corrected from 8.0"

- do:
indices.create:
index: test
body:
mappings:
properties:
entity_type: { "type": "keyword" }
join_field: { "type": "join", "relations": { "question": "answer", "person" : "address" } }
settings:
number_of_shards: 1

- do:
index:
index: test
id: 1
body: { "join_field": { "name": "question" }, "entity_type": "question" }

- do:
index:
index: test
id: 2
routing: 1
body: { "join_field": { "name": "answer", "parent": 1} , "entity_type": "answer" }

- do:
index:
index: test
id: 3
body: { "join_field": { "name": "person" }, "entity_type": "person" }

- do:
index:
index: test
routing: 3
id: 4
body: { "join_field": { "name": "address", "parent": 3 }, "entity_type": "address" }

- do:
indices.refresh: {}

- do:
search:
index: test
body:
query:
bool:
should:
- term:
entity_type: person
- has_parent:
parent_type: question
query:
match_all: {}
inner_hits: {}


- match: { hits.total.value: 2 }
- match: { hits.hits.0._id: "3" }
- match: { hits.hits.0.inner_hits.question.hits.total.value: 0}
- match: { hits.hits.1._id: "2" }
- match: { hits.hits.1.inner_hits.question.hits.total.value: 1}
- match: { hits.hits.1.inner_hits.question.hits.hits.0._id: "1"}