forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include the _index, _type and _id to nested search hits in the top_hi…
…ts and inner_hits response. Also include _type and _id for parent/child hits inside inner hits. In the case of top_hits aggregation the nested search hits are directly returned and are not grouped by a root or parent document, so it is important to include the _id and _index attributes in order to know to what documents these nested search hits belong to. Closes elastic#27053
- Loading branch information
Showing
6 changed files
with
119 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
...api-spec/src/main/resources/rest-api-spec/test/search.aggregation/200_top_hits_metric.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
--- | ||
"top_hits aggregation with nested documents": | ||
- skip: | ||
version: "5.99.99 - " | ||
reason: "5.x nodes don't include index or id in nested top hits" | ||
- do: | ||
indices.create: | ||
index: my-index | ||
body: | ||
settings: | ||
number_of_shards: 1 | ||
number_of_replicas: 0 | ||
mappings: | ||
doc: | ||
properties: | ||
users: | ||
type: nested | ||
|
||
- do: | ||
index: | ||
index: my-index | ||
type: doc | ||
id: 1 | ||
refresh: true | ||
body: | | ||
{ | ||
"group" : "fans", | ||
"users" : [ | ||
{ | ||
"first" : "John", | ||
"last" : "Smith" | ||
}, | ||
{ | ||
"first" : "Alice", | ||
"last" : "White" | ||
} | ||
] | ||
} | ||
- do: | ||
index: | ||
index: my-index | ||
type: doc | ||
id: 2 | ||
refresh: true | ||
body: | | ||
{ | ||
"group" : "fans", | ||
"users" : [ | ||
{ | ||
"first" : "Mark", | ||
"last" : "Doe" | ||
} | ||
] | ||
} | ||
- do: | ||
search: | ||
body: | ||
aggs: | ||
to-users: | ||
nested: | ||
path: users | ||
aggs: | ||
users: | ||
top_hits: | ||
sort: "users.last.keyword" | ||
|
||
- match: { hits.total: 2 } | ||
- length: { aggregations.to-users.users.hits.hits: 3 } | ||
- match: { aggregations.to-users.users.hits.hits.0._id: "2" } | ||
- match: { aggregations.to-users.users.hits.hits.0._index: my-index } | ||
- match: { aggregations.to-users.users.hits.hits.0._nested.field: users } | ||
- match: { aggregations.to-users.users.hits.hits.0._nested.offset: 0 } | ||
- match: { aggregations.to-users.users.hits.hits.1._id: "1" } | ||
- match: { aggregations.to-users.users.hits.hits.1._index: my-index } | ||
- match: { aggregations.to-users.users.hits.hits.1._nested.field: users } | ||
- match: { aggregations.to-users.users.hits.hits.1._nested.offset: 0 } | ||
- match: { aggregations.to-users.users.hits.hits.2._id: "1" } | ||
- match: { aggregations.to-users.users.hits.hits.2._index: my-index } | ||
- match: { aggregations.to-users.users.hits.hits.2._nested.field: users } | ||
- match: { aggregations.to-users.users.hits.hits.2._nested.offset: 1 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters