-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for scored named queries
Signed-off-by: Dharin Shah <8616130+Dharin-shah@users.noreply.github.com>
- Loading branch information
1 parent
332f4c5
commit 16b7c19
Showing
11 changed files
with
522 additions
and
115 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
103 changes: 103 additions & 0 deletions
103
rest-api-spec/src/main/resources/rest-api-spec/test/search/350_matched_queries.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,103 @@ | ||
setup: | ||
- skip: | ||
version: " - 2.12.0" | ||
reason: "implemented for versions post 2.12.0" | ||
|
||
--- | ||
"matched queries": | ||
- do: | ||
indices.create: | ||
index: test | ||
|
||
- do: | ||
bulk: | ||
refresh: true | ||
body: | ||
- '{ "index" : { "_index" : "test_1", "_id" : "1" } }' | ||
- '{"field" : 1 }' | ||
- '{ "index" : { "_index" : "test_1", "_id" : "2" } }' | ||
- '{"field" : [1, 2] }' | ||
|
||
- do: | ||
search: | ||
index: test_1 | ||
body: | ||
query: | ||
bool: { | ||
should: [ | ||
{ | ||
match: { | ||
field: { | ||
query: 1, | ||
_name: match_field_1 | ||
} | ||
} | ||
}, | ||
{ | ||
match: { | ||
field: { | ||
query: 2, | ||
_name: match_field_2, | ||
boost: 10 | ||
} | ||
} | ||
} | ||
] | ||
} | ||
|
||
- match: {hits.total.value: 2} | ||
- length: {hits.hits.0.matched_queries: 2} | ||
- match: {hits.hits.0.matched_queries: [ "match_field_1", "match_field_2" ]} | ||
- length: {hits.hits.1.matched_queries: 1} | ||
- match: {hits.hits.1.matched_queries: [ "match_field_1" ]} | ||
|
||
--- | ||
|
||
"matched queries with scores": | ||
- do: | ||
indices.create: | ||
index: test | ||
|
||
- do: | ||
bulk: | ||
refresh: true | ||
body: | ||
- '{ "index" : { "_index" : "test_1", "_id" : "1" } }' | ||
- '{"field" : 1 }' | ||
- '{ "index" : { "_index" : "test_1", "_id" : "2" } }' | ||
- '{"field" : [1, 2] }' | ||
|
||
- do: | ||
search: | ||
include_named_queries_score: true | ||
index: test_1 | ||
body: | ||
query: | ||
bool: { | ||
should: [ | ||
{ | ||
match: { | ||
field: { | ||
query: 1, | ||
_name: match_field_1 | ||
} | ||
} | ||
}, | ||
{ | ||
match: { | ||
field: { | ||
query: 2, | ||
_name: match_field_2, | ||
boost: 10 | ||
} | ||
} | ||
} | ||
] | ||
} | ||
|
||
- match: { hits.total.value: 2 } | ||
- length: { hits.hits.0.matched_queries: 2 } | ||
- match: { hits.hits.0.matched_queries.match_field_1: 1 } | ||
- match: { hits.hits.0.matched_queries.match_field_2: 10 } | ||
- length: { hits.hits.1.matched_queries: 1 } | ||
- match: { hits.hits.1.matched_queries.match_field_1: 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
Oops, something went wrong.