From df80fdbb20ce53d2d5fb4c74f240de00e4a62a48 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Wed, 7 Oct 2020 12:54:44 -0400 Subject: [PATCH 1/3] Add explanation to runtime field query This adds a `detail` to the output of `explain` for runtime fields queries that makes it clear that their score is entirely based on their boost. We don't have any tf/idf/norms/whatever to do any scoring - we just score `boost`. --- .../query/AbstractScriptFieldQuery.java | 14 ++++++++++++++ .../test/runtime_fields/10_keyword.yml | 15 +++++++++++++++ .../rest-api-spec/test/runtime_fields/20_long.yml | 15 +++++++++++++++ .../test/runtime_fields/30_double.yml | 15 +++++++++++++++ .../rest-api-spec/test/runtime_fields/40_date.yml | 15 +++++++++++++++ .../rest-api-spec/test/runtime_fields/50_ip.yml | 15 ++++++++++++++- .../test/runtime_fields/60_boolean.yml | 15 +++++++++++++++ 7 files changed, 103 insertions(+), 1 deletion(-) diff --git a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/query/AbstractScriptFieldQuery.java b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/query/AbstractScriptFieldQuery.java index dc4c0ec318a6c..b6bd40efc7411 100644 --- a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/query/AbstractScriptFieldQuery.java +++ b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/query/AbstractScriptFieldQuery.java @@ -10,6 +10,7 @@ import org.apache.lucene.search.ConstantScoreScorer; import org.apache.lucene.search.ConstantScoreWeight; import org.apache.lucene.search.DocIdSetIterator; +import org.apache.lucene.search.Explanation; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.Query; import org.apache.lucene.search.ScoreMode; @@ -80,6 +81,19 @@ public float matchCost() { }; return new ConstantScoreScorer(this, score(), scoreMode, twoPhase); } + + @Override + public Explanation explain(LeafReaderContext context, int doc) throws IOException { + Explanation constantExplanation = super.explain(context, doc); + if (constantExplanation.isMatch()) { + return Explanation.match( + constantExplanation.getValue(), + constantExplanation.getDescription(), + Explanation.match(boost, "runtime field query scoring boost") + ); + } + return constantExplanation; + } }; } diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/10_keyword.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/10_keyword.yml index 1bd38e88bb88c..1de5151fa358f 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/10_keyword.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/10_keyword.yml @@ -155,6 +155,21 @@ setup: - match: {hits.total.value: 1} - match: {hits.hits.0._source.voltage: 5.8} +--- +"explain term query": + - do: + search: + index: sensor + explain: true + body: + query: + term: + day_of_week: Monday + - match: {hits.hits.0._explanation.description: day_of_week:Monday} + - match: {hits.hits.0._explanation.details.0.value: 1.0} + - match: {hits.hits.0._explanation.details.0.description: 'runtime field query scoring boost'} + - match: {hits.hits.0._explanation.details.0.details: []} + --- "match query": - do: diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/20_long.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/20_long.yml index 45fb63a51d24b..c7c550d86cb95 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/20_long.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/20_long.yml @@ -172,6 +172,21 @@ setup: - match: {hits.total.value: 1} - match: {hits.hits.0._source.voltage: 5.8} +--- +"explain term query": + - do: + search: + index: sensor + explain: true + body: + query: + term: + voltage_times_ten: 58 + - match: {hits.hits.0._explanation.description: voltage_times_ten:58} + - match: {hits.hits.0._explanation.details.0.value: 1.0} + - match: {hits.hits.0._explanation.details.0.description: 'runtime field query scoring boost'} + - match: {hits.hits.0._explanation.details.0.details: []} + --- "nested": - do: diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/30_double.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/30_double.yml index 12b197519c6ce..ecf5605561596 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/30_double.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/30_double.yml @@ -194,3 +194,18 @@ setup: voltage_percent: 1.0 - match: {hits.total.value: 1} - match: {hits.hits.0._source.voltage: 5.8} + +--- +"explain term query": + - do: + search: + index: sensor + explain: true + body: + query: + term: + voltage_percent: 1.0 + - match: {hits.hits.0._explanation.description: voltage_percent:1.0} + - match: {hits.hits.0._explanation.details.0.value: 1.0} + - match: {hits.hits.0._explanation.details.0.description: 'runtime field query scoring boost'} + - match: {hits.hits.0._explanation.details.0.details: []} diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/40_date.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/40_date.yml index f41828400f42e..c2d87eee499b6 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/40_date.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/40_date.yml @@ -183,3 +183,18 @@ setup: tomorrow: 2018-01-19T17:41:34Z - match: {hits.total.value: 1} - match: {hits.hits.0._source.voltage: 4.0} + +--- +"explain term query": + - do: + search: + index: sensor + explain: true + body: + query: + term: + tomorrow: 2018-01-19T17:41:34Z + - match: {hits.hits.0._explanation.description: tomorrow:1516383694000} + - match: {hits.hits.0._explanation.details.0.value: 1.0} + - match: {hits.hits.0._explanation.details.0.description: 'runtime field query scoring boost'} + - match: {hits.hits.0._explanation.details.0.details: []} diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/50_ip.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/50_ip.yml index 843ea2cda257b..93c10f55ab8ca 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/50_ip.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/50_ip.yml @@ -160,4 +160,17 @@ setup: - match: {hits.total.value: 1} - match: {hits.hits.0._source.timestamp: "1998-04-30T14:31:27-05:00"} -# TODO tests for using the ip in a script. there is almost certainly whitelist "fun" here. +--- +"explain term query": + - do: + search: + index: http_logs + explain: true + body: + query: + term: + ip: 252.0.0.0 + - match: {hits.hits.0._explanation.description: ip:252.0.0.0} + - match: {hits.hits.0._explanation.details.0.value: 1.0} + - match: {hits.hits.0._explanation.details.0.description: 'runtime field query scoring boost'} + - match: {hits.hits.0._explanation.details.0.details: []} diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/60_boolean.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/60_boolean.yml index aaaccaf6c1cd3..b98c9b9de68a7 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/60_boolean.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/60_boolean.yml @@ -135,3 +135,18 @@ setup: timestamp: asc - match: {hits.total.value: 4} - match: {hits.hits.0._source.voltage: 5.6} + +--- +"explain term query": + - do: + search: + index: sensor + explain: true + body: + query: + term: + over_v: true + - match: {hits.hits.0._explanation.description: over_v:true} + - match: {hits.hits.0._explanation.details.0.value: 1.0} + - match: {hits.hits.0._explanation.details.0.description: 'runtime field query scoring boost'} + - match: {hits.hits.0._explanation.details.0.details: []} From 35a7d647690cb62eed04a4cc6346e2a052f835a0 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Thu, 8 Oct 2020 10:24:53 -0400 Subject: [PATCH 2/3] call out boost --- .../query/AbstractScriptFieldQuery.java | 19 +++++-- .../query/AbstractScriptFieldQueryTests.java | 53 +++++++++++++++++++ .../test/runtime_fields/10_keyword.yml | 28 +++++++++- .../test/runtime_fields/20_long.yml | 7 ++- .../test/runtime_fields/30_double.yml | 7 ++- .../test/runtime_fields/40_date.yml | 7 ++- .../test/runtime_fields/50_ip.yml | 7 ++- .../test/runtime_fields/60_boolean.yml | 7 ++- 8 files changed, 118 insertions(+), 17 deletions(-) create mode 100644 x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/query/AbstractScriptFieldQueryTests.java diff --git a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/query/AbstractScriptFieldQuery.java b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/query/AbstractScriptFieldQuery.java index b6bd40efc7411..82b2e63485238 100644 --- a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/query/AbstractScriptFieldQuery.java +++ b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/query/AbstractScriptFieldQuery.java @@ -86,11 +86,7 @@ public float matchCost() { public Explanation explain(LeafReaderContext context, int doc) throws IOException { Explanation constantExplanation = super.explain(context, doc); if (constantExplanation.isMatch()) { - return Explanation.match( - constantExplanation.getValue(), - constantExplanation.getDescription(), - Explanation.match(boost, "runtime field query scoring boost") - ); + return explainMatch(boost, constantExplanation.getDescription()); } return constantExplanation; } @@ -112,4 +108,17 @@ public boolean equals(Object obj) { AbstractScriptFieldQuery other = (AbstractScriptFieldQuery) obj; return script.equals(other.script) && fieldName.equals(other.fieldName); } + + final Explanation explainMatch(float boost, String description) { + return Explanation.match( + boost, + description, + Explanation.match( + boost, + "boost * runtime_field_score", + Explanation.match(boost, "boost"), + Explanation.match(1.0, "runtime_field_score is always 1") + ) + ); + } } diff --git a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/query/AbstractScriptFieldQueryTests.java b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/query/AbstractScriptFieldQueryTests.java new file mode 100644 index 0000000000000..096e01b287612 --- /dev/null +++ b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/query/AbstractScriptFieldQueryTests.java @@ -0,0 +1,53 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +package org.elasticsearch.xpack.runtimefields.query; + +import org.apache.lucene.search.Explanation; +import org.elasticsearch.script.Script; +import org.elasticsearch.test.ESTestCase; +import org.elasticsearch.xpack.runtimefields.mapper.AbstractFieldScript; + +import java.io.IOException; + +import static org.hamcrest.Matchers.equalTo; + +public class AbstractScriptFieldQueryTests extends ESTestCase { + public void testExplainMatched() throws IOException { + AbstractScriptFieldQuery query = new AbstractScriptFieldQuery( + new Script("test"), + "test", + null + ) { + @Override + protected boolean matches(AbstractFieldScript scriptContext, int docId) { + throw new UnsupportedOperationException(); + } + + @Override + public String toString(String field) { + throw new UnsupportedOperationException(); + } + }; + float boost = randomBoolean() ? 1.0f : randomFloat(); + String dummyDescription = randomAlphaOfLength(10); + assertThat( + query.explainMatch(boost, dummyDescription), + equalTo( + Explanation.match( + boost, + dummyDescription, + Explanation.match( + boost, + "boost * runtime_field_score", + Explanation.match(boost, "boost"), + Explanation.match(1.0, "runtime_field_score is always 1") + ) + ) + ) + ); + } +} diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/10_keyword.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/10_keyword.yml index 1de5151fa358f..ebdb7463a7fb8 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/10_keyword.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/10_keyword.yml @@ -167,8 +167,32 @@ setup: day_of_week: Monday - match: {hits.hits.0._explanation.description: day_of_week:Monday} - match: {hits.hits.0._explanation.details.0.value: 1.0} - - match: {hits.hits.0._explanation.details.0.description: 'runtime field query scoring boost'} - - match: {hits.hits.0._explanation.details.0.details: []} + - match: {hits.hits.0._explanation.details.0.description: 'boost * runtime_field_score'} + - match: {hits.hits.0._explanation.details.0.details.0.value: 1.0} + - match: {hits.hits.0._explanation.details.0.details.0.description: 'boost'} + - match: {hits.hits.0._explanation.details.0.details.1.value: 1.0} + - match: {hits.hits.0._explanation.details.0.details.1.description: 'runtime_field_score is always 1'} + +--- +"explain term query with boost": + - do: + search: + index: sensor + explain: true + body: + query: + term: + day_of_week: + value: Monday + boost: 7 + - match: {hits.hits.0._explanation.description: day_of_week:Monday^7.0} + - match: {hits.hits.0._explanation.details.0.value: 7.0} + - match: {hits.hits.0._explanation.details.0.description: 'boost * runtime_field_score'} + - match: {hits.hits.0._explanation.details.0.details.0.value: 7.0} + - match: {hits.hits.0._explanation.details.0.details.0.description: 'boost'} + - match: {hits.hits.0._explanation.details.0.details.1.value: 1.0} + - match: {hits.hits.0._explanation.details.0.details.1.description: 'runtime_field_score is always 1'} + --- "match query": diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/20_long.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/20_long.yml index c7c550d86cb95..ab9a23b65e31a 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/20_long.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/20_long.yml @@ -184,8 +184,11 @@ setup: voltage_times_ten: 58 - match: {hits.hits.0._explanation.description: voltage_times_ten:58} - match: {hits.hits.0._explanation.details.0.value: 1.0} - - match: {hits.hits.0._explanation.details.0.description: 'runtime field query scoring boost'} - - match: {hits.hits.0._explanation.details.0.details: []} + - match: {hits.hits.0._explanation.details.0.description: 'boost * runtime_field_score'} + - match: {hits.hits.0._explanation.details.0.details.0.value: 1.0} + - match: {hits.hits.0._explanation.details.0.details.0.description: 'boost'} + - match: {hits.hits.0._explanation.details.0.details.1.value: 1.0} + - match: {hits.hits.0._explanation.details.0.details.1.description: 'runtime_field_score is always 1'} --- "nested": diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/30_double.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/30_double.yml index ecf5605561596..1ee5c94419764 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/30_double.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/30_double.yml @@ -207,5 +207,8 @@ setup: voltage_percent: 1.0 - match: {hits.hits.0._explanation.description: voltage_percent:1.0} - match: {hits.hits.0._explanation.details.0.value: 1.0} - - match: {hits.hits.0._explanation.details.0.description: 'runtime field query scoring boost'} - - match: {hits.hits.0._explanation.details.0.details: []} + - match: {hits.hits.0._explanation.details.0.description: 'boost * runtime_field_score'} + - match: {hits.hits.0._explanation.details.0.details.0.value: 1.0} + - match: {hits.hits.0._explanation.details.0.details.0.description: 'boost'} + - match: {hits.hits.0._explanation.details.0.details.1.value: 1.0} + - match: {hits.hits.0._explanation.details.0.details.1.description: 'runtime_field_score is always 1'} diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/40_date.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/40_date.yml index c2d87eee499b6..48e385349ee15 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/40_date.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/40_date.yml @@ -196,5 +196,8 @@ setup: tomorrow: 2018-01-19T17:41:34Z - match: {hits.hits.0._explanation.description: tomorrow:1516383694000} - match: {hits.hits.0._explanation.details.0.value: 1.0} - - match: {hits.hits.0._explanation.details.0.description: 'runtime field query scoring boost'} - - match: {hits.hits.0._explanation.details.0.details: []} + - match: {hits.hits.0._explanation.details.0.description: 'boost * runtime_field_score'} + - match: {hits.hits.0._explanation.details.0.details.0.value: 1.0} + - match: {hits.hits.0._explanation.details.0.details.0.description: 'boost'} + - match: {hits.hits.0._explanation.details.0.details.1.value: 1.0} + - match: {hits.hits.0._explanation.details.0.details.1.description: 'runtime_field_score is always 1'} diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/50_ip.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/50_ip.yml index 93c10f55ab8ca..71ca4701623e1 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/50_ip.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/50_ip.yml @@ -172,5 +172,8 @@ setup: ip: 252.0.0.0 - match: {hits.hits.0._explanation.description: ip:252.0.0.0} - match: {hits.hits.0._explanation.details.0.value: 1.0} - - match: {hits.hits.0._explanation.details.0.description: 'runtime field query scoring boost'} - - match: {hits.hits.0._explanation.details.0.details: []} + - match: {hits.hits.0._explanation.details.0.description: 'boost * runtime_field_score'} + - match: {hits.hits.0._explanation.details.0.details.0.value: 1.0} + - match: {hits.hits.0._explanation.details.0.details.0.description: 'boost'} + - match: {hits.hits.0._explanation.details.0.details.1.value: 1.0} + - match: {hits.hits.0._explanation.details.0.details.1.description: 'runtime_field_score is always 1'} diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/60_boolean.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/60_boolean.yml index b98c9b9de68a7..ea8d7ee72fe25 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/60_boolean.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/60_boolean.yml @@ -148,5 +148,8 @@ setup: over_v: true - match: {hits.hits.0._explanation.description: over_v:true} - match: {hits.hits.0._explanation.details.0.value: 1.0} - - match: {hits.hits.0._explanation.details.0.description: 'runtime field query scoring boost'} - - match: {hits.hits.0._explanation.details.0.details: []} + - match: {hits.hits.0._explanation.details.0.description: 'boost * runtime_field_score'} + - match: {hits.hits.0._explanation.details.0.details.0.value: 1.0} + - match: {hits.hits.0._explanation.details.0.details.0.description: 'boost'} + - match: {hits.hits.0._explanation.details.0.details.1.value: 1.0} + - match: {hits.hits.0._explanation.details.0.details.1.description: 'runtime_field_score is always 1'} From 6ed0d5a71258f51aa6c30103e9cee6acb0d5c4d1 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Thu, 8 Oct 2020 11:23:20 -0400 Subject: [PATCH 3/3] Add test for script score --- .../test/runtime_fields/10_keyword.yml | 31 +++++++++++++++++++ .../test/runtime_fields/20_long.yml | 1 + .../test/runtime_fields/30_double.yml | 1 + .../test/runtime_fields/40_date.yml | 1 + .../test/runtime_fields/50_ip.yml | 1 + .../test/runtime_fields/60_boolean.yml | 1 + 6 files changed, 36 insertions(+) diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/10_keyword.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/10_keyword.yml index ebdb7463a7fb8..94df6f4996b08 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/10_keyword.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/10_keyword.yml @@ -165,6 +165,7 @@ setup: query: term: day_of_week: Monday + - match: {hits.hits.0._explanation.value: 1.0} - match: {hits.hits.0._explanation.description: day_of_week:Monday} - match: {hits.hits.0._explanation.details.0.value: 1.0} - match: {hits.hits.0._explanation.details.0.description: 'boost * runtime_field_score'} @@ -185,6 +186,7 @@ setup: day_of_week: value: Monday boost: 7 + - match: {hits.hits.0._explanation.value: 7.0} - match: {hits.hits.0._explanation.description: day_of_week:Monday^7.0} - match: {hits.hits.0._explanation.details.0.value: 7.0} - match: {hits.hits.0._explanation.details.0.description: 'boost * runtime_field_score'} @@ -193,6 +195,35 @@ setup: - match: {hits.hits.0._explanation.details.0.details.1.value: 1.0} - match: {hits.hits.0._explanation.details.0.details.1.description: 'runtime_field_score is always 1'} +--- +"explain term query wrapped in script score": + - do: + search: + index: sensor + explain: true + body: + query: + script_score: + script: + source: _score * 1000 + query: + term: + day_of_week: + value: Monday + boost: 7 + - match: {hits.hits.0._explanation.value: 7000.0} + - match: {hits.hits.0._explanation.description: "script score function, computed with script:\"Script{type=inline, lang='painless', idOrCode='_score * 1000', options={}, params={}}\""} + - match: {hits.hits.0._explanation.details.0.value: 7.0} + - match: {hits.hits.0._explanation.details.0.description: '_score: '} + - match: {hits.hits.0._explanation.details.0.details.0.value: 7.0} + - match: {hits.hits.0._explanation.details.0.details.0.description: day_of_week:Monday^7.0} + - match: {hits.hits.0._explanation.details.0.details.0.details.0.value: 7.0} + - match: {hits.hits.0._explanation.details.0.details.0.details.0.description: 'boost * runtime_field_score'} + - match: {hits.hits.0._explanation.details.0.details.0.details.0.details.0.value: 7.0} + - match: {hits.hits.0._explanation.details.0.details.0.details.0.details.0.description: 'boost'} + - match: {hits.hits.0._explanation.details.0.details.0.details.0.details.1.value: 1.0} + - match: {hits.hits.0._explanation.details.0.details.0.details.0.details.1.description: 'runtime_field_score is always 1'} + --- "match query": diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/20_long.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/20_long.yml index ab9a23b65e31a..bf211aceb704a 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/20_long.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/20_long.yml @@ -182,6 +182,7 @@ setup: query: term: voltage_times_ten: 58 + - match: {hits.hits.0._explanation.value: 1.0} - match: {hits.hits.0._explanation.description: voltage_times_ten:58} - match: {hits.hits.0._explanation.details.0.value: 1.0} - match: {hits.hits.0._explanation.details.0.description: 'boost * runtime_field_score'} diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/30_double.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/30_double.yml index 1ee5c94419764..db43647dc627a 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/30_double.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/30_double.yml @@ -205,6 +205,7 @@ setup: query: term: voltage_percent: 1.0 + - match: {hits.hits.0._explanation.value: 1.0} - match: {hits.hits.0._explanation.description: voltage_percent:1.0} - match: {hits.hits.0._explanation.details.0.value: 1.0} - match: {hits.hits.0._explanation.details.0.description: 'boost * runtime_field_score'} diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/40_date.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/40_date.yml index 48e385349ee15..a1a25302e4d93 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/40_date.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/40_date.yml @@ -194,6 +194,7 @@ setup: query: term: tomorrow: 2018-01-19T17:41:34Z + - match: {hits.hits.0._explanation.value: 1.0} - match: {hits.hits.0._explanation.description: tomorrow:1516383694000} - match: {hits.hits.0._explanation.details.0.value: 1.0} - match: {hits.hits.0._explanation.details.0.description: 'boost * runtime_field_score'} diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/50_ip.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/50_ip.yml index 71ca4701623e1..fdbad9e2241c9 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/50_ip.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/50_ip.yml @@ -170,6 +170,7 @@ setup: query: term: ip: 252.0.0.0 + - match: {hits.hits.0._explanation.value: 1.0} - match: {hits.hits.0._explanation.description: ip:252.0.0.0} - match: {hits.hits.0._explanation.details.0.value: 1.0} - match: {hits.hits.0._explanation.details.0.description: 'boost * runtime_field_score'} diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/60_boolean.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/60_boolean.yml index ea8d7ee72fe25..c14fe7084a851 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/60_boolean.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/60_boolean.yml @@ -146,6 +146,7 @@ setup: query: term: over_v: true + - match: {hits.hits.0._explanation.value: 1.0} - match: {hits.hits.0._explanation.description: over_v:true} - match: {hits.hits.0._explanation.details.0.value: 1.0} - match: {hits.hits.0._explanation.details.0.description: 'boost * runtime_field_score'}