Skip to content

Commit

Permalink
[Tests] Move templated _rank_eval tests (#30679)
Browse files Browse the repository at this point in the history
This change moves the ranking evaluation tests that use templates to the
existing yml rest tests instead of extending ESIntegTestCase.

Closes #30628
  • Loading branch information
Christoph Büscher authored May 24, 2018
1 parent 2b8d3e8 commit 9cb6b90
Show file tree
Hide file tree
Showing 4 changed files with 171 additions and 234 deletions.
3 changes: 0 additions & 3 deletions qa/smoke-test-rank-eval-with-mustache/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,3 @@ dependencies {
* and will be fixed later.
* Tracked by https://github.com/elastic/elasticsearch/issues/30628
*/
if ("zip".equals(integTestCluster.distribution)) {
integTestRunner.enabled = false
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
setup:

- do:
indices.create:
index: test
body:
settings:
index:
number_of_shards: 1
- do:
index:
index: test
type: _doc
id: 1
body: { "text": "berlin", "title" : "Berlin, Germany" }

- do:
index:
index: test
type: _doc
id: 2
body: { "text": "amsterdam" }

- do:
index:
index: test
type: _doc
id: 3
body: { "text": "amsterdam" }

- do:
index:
index: test
type: _doc
id: 4
body: { "text": "amsterdam" }

- do:
index:
index: test
type: _doc
id: 5
body: { "text": "amsterdam" }

- do:
index:
index: test
type: _doc
id: 6
body: { "text": "amsterdam" }

- do:
indices.refresh: {}

---
"Basic rank-eval request with template":

- skip:
version: " - 6.1.99"
reason: the ranking evaluation feature is available since 6.2

- do:
rank_eval:
body: {
"templates": [ { "id": "match", "template": {"source": "{\"query\": { \"match\" : {\"text\" : \"{{query_string}}\" }}}" }} ],
"requests" : [
{
"id": "amsterdam_query",
"params": { "query_string": "amsterdam" },
"template_id": "match",
"ratings": [
{"_index": "test", "_id": "2", "rating": 1},
{"_index": "test", "_id": "3", "rating": 1},
{"_index": "test", "_id": "4", "rating": 1},
{"_index": "test", "_id": "5", "rating": 1},]
},
{
"id" : "berlin_query",
"params": { "query_string": "berlin" },
"template_id": "match",
"ratings": [{"_index": "test", "_id": "1", "rating": 1}]
}
],
"metric" : { "precision": { }}
}

- match: {quality_level: 0.9}
- match: {details.amsterdam_query.unknown_docs.0._id: "6"}

---
"Test illegal request parts":

- do:
catch: /Query in rated requests should not contain aggregations./
rank_eval:
body: {
"templates": [ { "id": "match", "template": {"source": "{ \"aggs\" : { \"avg_grade\" : { \"avg\" : { \"field\" : \"grade\" }}}}" }} ],
"requests" : [
{
"id": "amsterdam_query",
"params": { "query_string": "amsterdam" },
"template_id": "match",
"ratings": []
}
],
"metric" : { "precision": { }}
}

- do:
catch: /Query in rated requests should not contain a suggest section./
rank_eval:
body: {
"templates": [ { "id": "match", "template": {"source": "{\"suggest\" : {\"my-suggestion\" : {\"text\" : \"Elastic\",\"term\" : {\"field\" : \"message\"}}}}" }} ],
"requests" : [
{
"id": "amsterdam_query",
"params": { "query_string": "amsterdam" },
"template_id": "match",
"ratings": []
}
],
"metric" : { "precision": { }}
}

- do:
catch: /Query in rated requests should not contain a highlighter section./
rank_eval:
body: {
"templates": [ { "id": "match", "template": {"source": "{\"highlight\" : { \"fields\" : {\"content\" : {}}}}" }} ],
"requests" : [
{
"id": "amsterdam_query",
"params": { "query_string": "amsterdam" },
"template_id": "match",
"ratings": []
}
],
"metric" : { "precision": { }}
}

- do:
catch: /Query in rated requests should not use profile./
rank_eval:
body: {
"templates": [ { "id": "match", "template": {"source": "{\"profile\" : \"true\" }" }} ],
"requests" : [
{
"id": "amsterdam_query",
"params": { "query_string": "amsterdam" },
"template_id": "match",
"ratings": []
}
],
"metric" : { "precision": { }}
}

- do:
catch: /Query in rated requests should not use explain./
rank_eval:
body: {
"templates": [ { "id": "match", "template": {"source": "{\"explain\" : \"true\" }" }} ],
"requests" : [
{
"id": "amsterdam_query",
"params": { "query_string": "amsterdam" },
"template_id": "match",
"ratings": []
}
],
"metric" : { "precision": { }}
}
Loading

0 comments on commit 9cb6b90

Please sign in to comment.