-
Notifications
You must be signed in to change notification settings - Fork 25k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add second level of field collapsing (#31808)
Put second level collapse under inner_hits Closes #24855
- Loading branch information
1 parent
63e45c8
commit 7128bf4
Showing
4 changed files
with
296 additions
and
4 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
141 changes: 141 additions & 0 deletions
141
rest-api-spec/src/main/resources/rest-api-spec/test/search/115_multiple_field_collapsing.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,141 @@ | ||
--- | ||
"two levels fields collapsing": | ||
- skip: | ||
version: " - 6.3.99" | ||
reason: using multiple field collapsing from 6.4 on | ||
- do: | ||
indices.create: | ||
index: addresses | ||
body: | ||
settings: | ||
number_of_shards: 1 | ||
number_of_replicas: 1 | ||
mappings: | ||
_doc: | ||
properties: | ||
country: {"type": "keyword"} | ||
city: {"type": "keyword"} | ||
address: {"type": "text"} | ||
|
||
- do: | ||
bulk: | ||
refresh: true | ||
body: | ||
- '{ "index" : { "_index" : "addresses", "_type" : "_doc", "_id" : "1" } }' | ||
- '{"country" : "Canada", "city" : "Saskatoon", "address" : "701 Victoria Avenue" }' | ||
- '{ "index" : { "_index" : "addresses", "_type" : "_doc", "_id" : "2" } }' | ||
- '{"country" : "Canada", "city" : "Toronto", "address" : "74 Victoria Street, Suite, 74 Victoria Street, Suite 300" }' | ||
- '{ "index" : { "_index" : "addresses", "_type" : "_doc", "_id" : "3" } }' | ||
- '{"country" : "Canada", "city" : "Toronto", "address" : "350 Victoria St" }' | ||
- '{ "index" : { "_index" : "addresses", "_type" : "_doc", "_id" : "4" } }' | ||
- '{"country" : "Canada", "city" : "Toronto", "address" : "20 Victoria Street" }' | ||
- '{ "index" : { "_index" : "addresses", "_type" : "_doc", "_id" : "5" } }' | ||
- '{"country" : "UK", "city" : "London", "address" : "58 Victoria Street" }' | ||
- '{ "index" : { "_index" : "addresses", "_type" : "_doc", "_id" : "6" } }' | ||
- '{"country" : "UK", "city" : "London", "address" : "Victoria Street Victoria Palace Theatre" }' | ||
- '{ "index" : { "_index" : "addresses", "_type" : "_doc", "_id" : "7" } }' | ||
- '{"country" : "UK", "city" : "Manchester", "address" : "75 Victoria street Westminster" }' | ||
- '{ "index" : { "_index" : "addresses", "_type" : "_doc", "_id" : "8" } }' | ||
- '{"country" : "UK", "city" : "London", "address" : "Victoria Station Victoria Arcade" }' | ||
|
||
|
||
# ************* error if internal collapse contains inner_hits | ||
- do: | ||
catch: /parse_exception/ | ||
search: | ||
index: addresses | ||
body: | ||
query: { "match" : { "address" : "victoria" }} | ||
collapse: | ||
field: country | ||
inner_hits: | ||
collapse: | ||
field : city | ||
inner_hits: {} | ||
|
||
|
||
# ************* error if internal collapse contains another collapse | ||
- do: | ||
catch: /parse_exception/ | ||
search: | ||
index: addresses | ||
body: | ||
query: { "match" : { "address" : "victoria" }} | ||
collapse: | ||
field: country | ||
inner_hits: | ||
collapse: | ||
field : city | ||
collapse: { field: city } | ||
|
||
|
||
|
||
# ************* top scored | ||
- do: | ||
search: | ||
index: addresses | ||
body: | ||
query: { "match" : { "address" : "victoria" }} | ||
collapse: | ||
field: country | ||
inner_hits: | ||
name: by_location | ||
size: 3 | ||
collapse: | ||
field : city | ||
|
||
- match: { hits.total: 8 } | ||
- length: { hits.hits: 2 } | ||
- match: { hits.hits.0.fields.country: ["UK"] } | ||
- match: { hits.hits.0.inner_hits.by_location.hits.total: 4 } | ||
# 2 inner hits returned instead of requested 3 as they are collapsed by city | ||
- length: { hits.hits.0.inner_hits.by_location.hits.hits : 2} | ||
- match: { hits.hits.0.inner_hits.by_location.hits.hits.0._id: "8" } | ||
- match: { hits.hits.0.inner_hits.by_location.hits.hits.0.fields.city: ["London"] } | ||
- match: { hits.hits.0.inner_hits.by_location.hits.hits.1._id: "7" } | ||
- match: { hits.hits.0.inner_hits.by_location.hits.hits.1.fields.city: ["Manchester"] } | ||
|
||
- match: { hits.hits.1.fields.country: ["Canada"] } | ||
- match: { hits.hits.1.inner_hits.by_location.hits.total: 4 } | ||
# 2 inner hits returned instead of requested 3 as they are collapsed by city | ||
- length: { hits.hits.1.inner_hits.by_location.hits.hits : 2 } | ||
- match: { hits.hits.1.inner_hits.by_location.hits.hits.0._id: "1" } | ||
- match: { hits.hits.1.inner_hits.by_location.hits.hits.0.fields.city: ["Saskatoon"] } | ||
- match: { hits.hits.1.inner_hits.by_location.hits.hits.1._id: "3" } | ||
- match: { hits.hits.1.inner_hits.by_location.hits.hits.1.fields.city: ["Toronto"] } | ||
|
||
|
||
# ************* sorted | ||
- do: | ||
search: | ||
index: addresses | ||
body: | ||
query: { "match" : { "address" : "victoria" }} | ||
collapse: | ||
field: country | ||
inner_hits: | ||
name: by_location | ||
size: 3 | ||
sort: [{ "city": "desc" }] | ||
collapse: | ||
field : city | ||
|
||
- match: { hits.total: 8 } | ||
- length: { hits.hits: 2 } | ||
- match: { hits.hits.0.fields.country: ["UK"] } | ||
- match: { hits.hits.0.inner_hits.by_location.hits.total: 4 } | ||
# 2 inner hits returned instead of requested 3 as they are collapsed by city | ||
- length: { hits.hits.0.inner_hits.by_location.hits.hits : 2} | ||
- match: { hits.hits.0.inner_hits.by_location.hits.hits.0._id: "7" } | ||
- match: { hits.hits.0.inner_hits.by_location.hits.hits.0.fields.city: ["Manchester"] } | ||
- match: { hits.hits.0.inner_hits.by_location.hits.hits.1._id: "5" } | ||
- match: { hits.hits.0.inner_hits.by_location.hits.hits.1.fields.city: ["London"] } | ||
|
||
- match: { hits.hits.1.fields.country: ["Canada"] } | ||
- match: { hits.hits.1.inner_hits.by_location.hits.total: 4 } | ||
# 2 inner hits returned instead of requested 3 as they are collapsed by city | ||
- length: { hits.hits.1.inner_hits.by_location.hits.hits : 2 } | ||
- match: { hits.hits.1.inner_hits.by_location.hits.hits.0._id: "2" } | ||
- match: { hits.hits.1.inner_hits.by_location.hits.hits.0.fields.city: ["Toronto"] } | ||
- match: { hits.hits.1.inner_hits.by_location.hits.hits.1._id: "1" } | ||
- match: { hits.hits.1.inner_hits.by_location.hits.hits.1.fields.city: ["Saskatoon"] } |
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