rest-api-spec.test.search.aggregation.200_top_hits_metric.yml Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rest-api-spec Show documentation
Show all versions of rest-api-spec Show documentation
OpenSearch subproject :rest-api-spec
setup:
- do:
indices.create:
index: my-index
body:
settings:
number_of_shards: 1
number_of_replicas: 0
mappings:
properties:
users:
type: nested
- do:
index:
index: my-index
id: 1
refresh: true
body: |
{
"group" : "fans",
"users" : [
{
"first" : "John",
"last" : "Smith"
},
{
"first" : "Alice",
"last" : "White"
}
]
}
- do:
index:
index: my-index
id: 2
refresh: true
body: |
{
"group" : "fans",
"users" : [
{
"first" : "Mark",
"last" : "Doe"
}
]
}
---
"top_hits aggregation with nested documents":
- do:
search:
rest_total_hits_as_int: true
index: my-index
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 }
---
"top_hits aggregation with nested documents and disabled _source":
- skip:
version: " - 7.10.1"
reason: "bug fix introduced in 7.10.2"
- do:
indices.create:
index: disabled-source
body:
settings:
number_of_shards: 1
number_of_replicas: 0
mappings:
_source:
enabled: false
properties:
users:
type: nested
- do:
index:
index: disabled-source
id: 1
refresh: true
body:
users:
- first: "John"
last: "Smith"
- do:
search:
index: disabled-source
rest_total_hits_as_int: true
body:
aggs:
to-users:
nested:
path: users
aggs:
users:
top_hits: {}
- match: { hits.total: 1 }
- length: { aggregations.to-users.users.hits.hits: 1 }
- match: { aggregations.to-users.users.hits.hits.0._id: "1" }
- match: { aggregations.to-users.users.hits.hits.0._index: disabled-source }
- match: { aggregations.to-users.users.hits.hits.0._nested.field: users }
- match: { aggregations.to-users.users.hits.hits.0._nested.offset: 0 }
- is_false: aggregations.to-users.users.hits.hits.0._source
---
"top_hits aggregation with sequence numbers":
- do:
search:
index: my-index
rest_total_hits_as_int: true
body:
aggs:
groups:
terms:
field: group.keyword
aggs:
users:
top_hits:
sort: "users.last.keyword"
seq_no_primary_term: true
- match: { hits.total: 2 }
- length: { aggregations.groups.buckets.0.users.hits.hits: 2 }
- match: { aggregations.groups.buckets.0.users.hits.hits.0._id: "1" }
- match: { aggregations.groups.buckets.0.users.hits.hits.0._index: my-index }
- gte: { aggregations.groups.buckets.0.users.hits.hits.0._seq_no: 0 }
- gte: { aggregations.groups.buckets.0.users.hits.hits.0._primary_term: 1 }
- match: { aggregations.groups.buckets.0.users.hits.hits.1._id: "2" }
- match: { aggregations.groups.buckets.0.users.hits.hits.1._index: my-index }
- gte: { aggregations.groups.buckets.0.users.hits.hits.1._seq_no: 0 }
- gte: { aggregations.groups.buckets.0.users.hits.hits.1._primary_term: 1 }
© 2015 - 2024 Weber Informatics LLC | Privacy Policy