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.
- Loading branch information
Showing
4 changed files
with
109 additions
and
4 deletions.
There are no files selected for viewing
107 changes: 107 additions & 0 deletions
107
...rc/yamlRestTest/resources/rest-api-spec/test/search/112_field_collapsing_with_rescore.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,107 @@ | ||
setup: | ||
- skip: | ||
version: " - 8.14.99" | ||
reason: Collapse with rescore added in 8.15.0 | ||
- do: | ||
indices.create: | ||
index: products | ||
body: | ||
mappings: | ||
properties: | ||
product_id: { type: keyword } | ||
description: { type: text } | ||
popularity: { type: integer } | ||
|
||
- do: | ||
bulk: | ||
index: products | ||
refresh: true | ||
body: | ||
- '{"index": {"_id": "1", "routing": "0"}}' | ||
- '{"product_id": "0", "description": "flat tv 4K HDR", "score": 2, "popularity": 30}' | ||
- '{"index": {"_id": "2", "routing": "10"}}' | ||
- '{"product_id": "10", "description": "LED Smart TV 32", "score": 5, "popularity": 100}' | ||
- '{"index": {"_id": "3", "routing": "10"}}' | ||
- '{"product_id": "10", "description": "LED Smart TV 65", "score": 10, "popularity": 50}' | ||
- '{"index": {"_id": "4", "routing": "0"}}' | ||
- '{"product_id": "0", "description": "flat tv", "score": 1, "popularity": 10}' | ||
- '{"index": {"_id": "5", "routing": "129"}}' | ||
- '{"product_id": "129", "description": "just a tv", "score": 100, "popularity": 3}' | ||
|
||
--- | ||
"field collapsing and rescore": | ||
- do: | ||
search: | ||
index: products | ||
body: | ||
query: | ||
bool: | ||
filter: | ||
match: | ||
description: "tv" | ||
should: | ||
script_score: | ||
query: { match_all: { } } | ||
script: | ||
source: "doc['score'].value" | ||
collapse: | ||
field: product_id | ||
rescore: | ||
query: | ||
rescore_query: | ||
script_score: | ||
query: { match_all: { } } | ||
script: | ||
source: "doc['popularity'].value" | ||
query_weight: 0 | ||
rescore_query_weight: 1 | ||
|
||
|
||
- match: {hits.total.value: 5 } | ||
- length: {hits.hits: 3 } | ||
- match: {hits.hits.0._id: "3"} | ||
- match: {hits.hits.0._score: 50} | ||
- match: {hits.hits.0.fields.product_id: ["10"]} | ||
- match: { hits.hits.1._id: "1" } | ||
- match: { hits.hits.1._score: 30 } | ||
- match: { hits.hits.1.fields.product_id: ["0"] } | ||
- match: { hits.hits.2._id: "5" } | ||
- match: { hits.hits.2._score: 3 } | ||
- match: { hits.hits.2.fields.product_id: ["129"] } | ||
|
||
--- | ||
"field collapsing and rescore with window_size": | ||
- do: | ||
search: | ||
index: products | ||
body: | ||
query: | ||
bool: | ||
filter: | ||
match: | ||
description: "tv" | ||
should: | ||
script_score: | ||
query: { match_all: { } } | ||
script: | ||
source: "doc['score'].value" | ||
collapse: | ||
field: product_id | ||
rescore: | ||
window_size: 2 | ||
query: | ||
rescore_query: | ||
script_score: | ||
query: { match_all: { } } | ||
script: | ||
source: "doc['popularity'].value" | ||
query_weight: 0 | ||
rescore_query_weight: 1 | ||
size: 1 | ||
|
||
|
||
- match: {hits.total.value: 5 } | ||
- length: {hits.hits: 1 } | ||
- match: {hits.hits.0._id: "3"} | ||
- match: {hits.hits.0._score: 50} | ||
- match: {hits.hits.0.fields.product_id: ["10"]} |
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