File tree 2 files changed +77
-0
lines changed
main/java/org/elasticsearch/join/query
test/resources/rest-api-spec/test
2 files changed +77
-0
lines changed Original file line number Diff line number Diff line change @@ -156,6 +156,10 @@ public TopDocs[] topDocs(SearchHit[] hits) throws IOException {
156
156
.build ();
157
157
} else {
158
158
String parentId = getSortedDocValue (parentIdFieldMapper .name (), context , hit .docId ());
159
+ if (parentId == null ) {
160
+ result [i ] = Lucene .EMPTY_TOP_DOCS ;
161
+ continue ;
162
+ }
159
163
q = context .mapperService ().fullName (IdFieldMapper .NAME ).termQuery (parentId , qsc );
160
164
}
161
165
Original file line number Diff line number Diff line change
1
+ ---
2
+ " Test two sub-queries with only one having inner_hits " :
3
+ - skip :
4
+ version : " - 6.8.6"
5
+ reason : " The bug was corrected from 6.8.7"
6
+
7
+ - do :
8
+ indices.create :
9
+ index : test
10
+ body :
11
+ mappings :
12
+ doc :
13
+ properties :
14
+ entity_type : { "type": "keyword" }
15
+ join_field : { "type": "join", "relations": { "question": "answer", "person" : "address" } }
16
+ settings :
17
+ number_of_shards : 1
18
+
19
+ - do :
20
+ index :
21
+ index : test
22
+ type : doc
23
+ id : 1
24
+ body : { "join_field": { "name": "question" }, "entity_type": "question" }
25
+
26
+ - do :
27
+ index :
28
+ index : test
29
+ type : doc
30
+ id : 2
31
+ routing : 1
32
+ body : { "join_field": { "name": "answer", "parent": 1} , "entity_type": "answer" }
33
+
34
+ - do :
35
+ index :
36
+ index : test
37
+ type : doc
38
+ id : 3
39
+ body : { "join_field": { "name": "person" }, "entity_type": "person" }
40
+
41
+ - do :
42
+ index :
43
+ index : test
44
+ type : doc
45
+ routing : 3
46
+ id : 4
47
+ body : { "join_field": { "name": "address", "parent": 3 }, "entity_type": "address" }
48
+
49
+ - do :
50
+ indices.refresh : {}
51
+
52
+ - do :
53
+ search :
54
+ index : test
55
+ body :
56
+ query :
57
+ bool :
58
+ should :
59
+ - term :
60
+ entity_type : person
61
+ - has_parent :
62
+ parent_type : question
63
+ query :
64
+ match_all : {}
65
+ inner_hits : {}
66
+
67
+
68
+ - match : { hits.total: 2 }
69
+ - match : { hits.hits.0._id: "3" }
70
+ - match : { hits.hits.0.inner_hits.question.hits.total: 0}
71
+ - match : { hits.hits.1._id: "2" }
72
+ - match : { hits.hits.1.inner_hits.question.hits.total: 1}
73
+ - match : { hits.hits.1.inner_hits.question.hits.hits.0._id: "1"}
You can’t perform that action at this time.
0 commit comments