Deprecate legacy params from range query (#113286)
Deprecate to, from, include_lower, include_upper range query params.
These params have been removed from our documentation in v. 0.90.4 (d6ecdecc19
),
but did not got through deprecation cycle.
These params to be removed in v9.0.
Related to #81276
Closes #48538
This commit is contained in:
parent
437ce66200
commit
c18c531d72
|
@ -0,0 +1,10 @@
|
|||
pr: 113286
|
||||
summary: Deprecate legacy params from range query
|
||||
area: Search
|
||||
type: deprecation
|
||||
issues: []
|
||||
deprecation:
|
||||
title: Deprecate legacy params from range query
|
||||
area: REST API
|
||||
details: Range query will not longer accept `to`, `from`, `include_lower`, and `include_upper` parameters.
|
||||
impact: Instead use `gt`, `gte`, `lt` and `lte` parameters.
|
|
@ -165,7 +165,7 @@ Example:
|
|||
POST /sales/_search?size=0
|
||||
{
|
||||
"query": {
|
||||
"constant_score": { "filter": { "range": { "price": { "to": "500" } } } }
|
||||
"constant_score": { "filter": { "range": { "price": { "lte": "500" } } } }
|
||||
},
|
||||
"aggs": {
|
||||
"prices": {
|
||||
|
@ -202,7 +202,7 @@ Example:
|
|||
POST /sales/_search?size=0
|
||||
{
|
||||
"query": {
|
||||
"constant_score": { "filter": { "range": { "price": { "to": "500" } } } }
|
||||
"constant_score": { "filter": { "range": { "price": { "lte": "500" } } } }
|
||||
},
|
||||
"aggs": {
|
||||
"prices": {
|
||||
|
|
|
@ -135,7 +135,7 @@ GET .watcher-history*/_search?pretty
|
|||
"bool" : {
|
||||
"must" : [
|
||||
{ "match" : { "result.condition.met" : true }},
|
||||
{ "range" : { "result.execution_time" : { "from" : "now-10s" }}}
|
||||
{ "range" : { "result.execution_time" : { "gte" : "now-10s" }}}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -119,8 +119,8 @@ time of the watch:
|
|||
{
|
||||
"range" : {
|
||||
"@timestamp" : {
|
||||
"from" : "{{ctx.trigger.scheduled_time}}||-30s",
|
||||
"to" : "{{ctx.trigger.triggered_time}}"
|
||||
"gte" : "{{ctx.trigger.scheduled_time}}||-30s",
|
||||
"lte" : "{{ctx.trigger.triggered_time}}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -159,8 +159,8 @@ The following is an example of using templates that refer to provided parameters
|
|||
{
|
||||
"range" : {
|
||||
"@timestamp" : {
|
||||
"from" : "{{ctx.trigger.scheduled_time}}||-30s",
|
||||
"to" : "{{ctx.trigger.triggered_time}}"
|
||||
"gte" : "{{ctx.trigger.scheduled_time}}||-30s",
|
||||
"lte" : "{{ctx.trigger.triggered_time}}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,3 +25,7 @@ testClusters.configureEach {
|
|||
// Modules who's integration is explicitly tested in integration tests
|
||||
module ':modules:lang-mustache'
|
||||
}
|
||||
|
||||
tasks.named("yamlRestCompatTestTransform").configure({ task ->
|
||||
task.skipTest("rank_eval/30_failures/Response format", "warning does not exist for compatibility")
|
||||
})
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
},
|
||||
{
|
||||
"id" : "invalid_query",
|
||||
"request": { "query": { "range" : { "bar" : { "from" : "Basel", "time_zone": "+01:00" }}}},
|
||||
"request": { "query": { "range" : { "bar" : { "gte" : "Basel", "time_zone": "+01:00" }}}},
|
||||
"ratings": [{"_index": "foo", "_id": "doc1", "rating": 1}]
|
||||
}
|
||||
],
|
||||
|
|
|
@ -22,3 +22,7 @@ dependencies {
|
|||
api project(':libs:elasticsearch-grok')
|
||||
api project(':libs:elasticsearch-dissect')
|
||||
}
|
||||
|
||||
tasks.named("yamlRestCompatTestTransform").configure({ task ->
|
||||
task.skipTestsByFilePattern("**/runtime_fields/110_composite.yml", "warning does not exist for compatibility")
|
||||
})
|
||||
|
|
|
@ -83,8 +83,8 @@ query:
|
|||
query:
|
||||
range:
|
||||
http.clientip:
|
||||
from: 232.0.0.0
|
||||
to: 253.0.0.0
|
||||
gte: 232.0.0.0
|
||||
lte: 253.0.0.0
|
||||
- match: { hits.total.value: 4 }
|
||||
|
||||
---
|
||||
|
|
|
@ -266,6 +266,9 @@ tests:
|
|||
- class: org.elasticsearch.xpack.ml.integration.MlJobIT
|
||||
method: testDeleteJob_TimingStatsDocumentIsDeleted
|
||||
issue: https://github.com/elastic/elasticsearch/issues/113370
|
||||
- class: org.elasticsearch.backwards.MixedClusterClientYamlTestSuiteIT
|
||||
method: test {p0=search/500_date_range/from, to, include_lower, include_upper deprecated}
|
||||
issue: https://github.com/elastic/elasticsearch/pull/113286
|
||||
- class: org.elasticsearch.xpack.esql.EsqlAsyncSecurityIT
|
||||
method: testLimitedPrivilege
|
||||
issue: https://github.com/elastic/elasticsearch/issues/113419
|
||||
|
|
|
@ -56,4 +56,6 @@ tasks.named("precommit").configure {
|
|||
|
||||
tasks.named("yamlRestCompatTestTransform").configure({ task ->
|
||||
task.skipTest("tsdb/140_routing_path/multi-value routing path field", "Multi-value routing paths are allowed now. See #112645")
|
||||
task.skipTest("indices.sort/10_basic/Index Sort", "warning does not exist for compatibility")
|
||||
task.skipTest("search/330_fetch_fields/Test search rewrite", "warning does not exist for compatibility")
|
||||
})
|
||||
|
|
|
@ -101,7 +101,7 @@
|
|||
index: test
|
||||
body:
|
||||
sort: ["rank"]
|
||||
query: {"range": { "rank": { "from": 0 } } }
|
||||
query: {"range": { "rank": { "gte": 0 } } }
|
||||
track_total_hits: false
|
||||
size: 1
|
||||
|
||||
|
@ -142,7 +142,7 @@
|
|||
index: test
|
||||
body:
|
||||
sort: ["rank"]
|
||||
query: {"range": { "rank": { "from": 0 } } }
|
||||
query: {"range": { "rank": { "gte": 0 } } }
|
||||
track_total_hits: false
|
||||
size: 3
|
||||
|
||||
|
@ -160,6 +160,6 @@
|
|||
scroll: 1m
|
||||
body:
|
||||
sort: ["rank"]
|
||||
query: {"range": { "rank": { "from": 0 } } }
|
||||
query: {"range": { "rank": { "gte": 0 } } }
|
||||
track_total_hits: false
|
||||
size: 3
|
||||
|
|
|
@ -252,7 +252,7 @@
|
|||
query:
|
||||
range:
|
||||
date:
|
||||
from: "1990-12-29T22:30:00.000Z"
|
||||
gte: "1990-12-29T22:30:00.000Z"
|
||||
fields:
|
||||
- field: date
|
||||
format: "yyyy/MM/dd"
|
||||
|
|
|
@ -123,3 +123,29 @@ setup:
|
|||
- match: { hits.total: 1 }
|
||||
- length: { hits.hits: 1 }
|
||||
- match: { hits.hits.0._id: "4" }
|
||||
|
||||
|
||||
---
|
||||
"from, to, include_lower, include_upper deprecated":
|
||||
- requires:
|
||||
cluster_features: "gte_v8.16.0"
|
||||
reason: 'from, to, include_lower, include_upper parameters are deprecated since 8.16.0'
|
||||
test_runner_features: warnings
|
||||
|
||||
- do:
|
||||
warnings:
|
||||
- "Deprecated field [from] used, this field is unused and will be removed entirely"
|
||||
- "Deprecated field [to] used, this field is unused and will be removed entirely"
|
||||
- "Deprecated field [include_lower] used, this field is unused and will be removed entirely"
|
||||
- "Deprecated field [include_upper] used, this field is unused and will be removed entirely"
|
||||
search:
|
||||
index: dates
|
||||
body:
|
||||
sort: field
|
||||
query:
|
||||
range:
|
||||
date:
|
||||
from: 1000
|
||||
to: 2023
|
||||
include_lower: false
|
||||
include_upper: false
|
||||
|
|
|
@ -45,10 +45,10 @@ public class RangeQueryBuilder extends AbstractQueryBuilder<RangeQueryBuilder> i
|
|||
|
||||
public static final ParseField LTE_FIELD = new ParseField("lte");
|
||||
public static final ParseField GTE_FIELD = new ParseField("gte");
|
||||
public static final ParseField FROM_FIELD = new ParseField("from");
|
||||
public static final ParseField TO_FIELD = new ParseField("to");
|
||||
private static final ParseField INCLUDE_LOWER_FIELD = new ParseField("include_lower");
|
||||
private static final ParseField INCLUDE_UPPER_FIELD = new ParseField("include_upper");
|
||||
public static final ParseField FROM_FIELD = new ParseField("from").withAllDeprecated();
|
||||
public static final ParseField TO_FIELD = new ParseField("to").withAllDeprecated();
|
||||
private static final ParseField INCLUDE_LOWER_FIELD = new ParseField("include_lower").withAllDeprecated();
|
||||
private static final ParseField INCLUDE_UPPER_FIELD = new ParseField("include_upper").withAllDeprecated();
|
||||
public static final ParseField GT_FIELD = new ParseField("gt");
|
||||
public static final ParseField LT_FIELD = new ParseField("lt");
|
||||
private static final ParseField TIME_ZONE_FIELD = new ParseField("time_zone");
|
||||
|
|
|
@ -35,8 +35,6 @@ import java.io.IOException;
|
|||
import java.time.Instant;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.elasticsearch.index.query.QueryBuilders.rangeQuery;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
@ -111,44 +109,6 @@ public class RangeQueryBuilderTests extends AbstractQueryTestCase<RangeQueryBuil
|
|||
return query;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, RangeQueryBuilder> getAlternateVersions() {
|
||||
Map<String, RangeQueryBuilder> alternateVersions = new HashMap<>();
|
||||
RangeQueryBuilder rangeQueryBuilder = new RangeQueryBuilder(INT_FIELD_NAME);
|
||||
|
||||
rangeQueryBuilder.includeLower(randomBoolean());
|
||||
rangeQueryBuilder.includeUpper(randomBoolean());
|
||||
|
||||
if (randomBoolean()) {
|
||||
rangeQueryBuilder.from(randomIntBetween(1, 100));
|
||||
}
|
||||
|
||||
if (randomBoolean()) {
|
||||
rangeQueryBuilder.to(randomIntBetween(101, 200));
|
||||
}
|
||||
|
||||
String query = Strings.format(
|
||||
"""
|
||||
{
|
||||
"range":{
|
||||
"%s": {
|
||||
"include_lower":%s,
|
||||
"include_upper":%s,
|
||||
"from":%s,
|
||||
"to":%s
|
||||
}
|
||||
}
|
||||
}""",
|
||||
INT_FIELD_NAME,
|
||||
rangeQueryBuilder.includeLower(),
|
||||
rangeQueryBuilder.includeUpper(),
|
||||
rangeQueryBuilder.from(),
|
||||
rangeQueryBuilder.to()
|
||||
);
|
||||
alternateVersions.put(query, rangeQueryBuilder);
|
||||
return alternateVersions;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doAssertLuceneQuery(RangeQueryBuilder queryBuilder, Query query, SearchExecutionContext context) throws IOException {
|
||||
String expectedFieldName = expectedFieldName(queryBuilder.fieldName());
|
||||
|
@ -420,8 +380,8 @@ public class RangeQueryBuilderTests extends AbstractQueryTestCase<RangeQueryBuil
|
|||
{
|
||||
"range" : {
|
||||
"timestamp" : {
|
||||
"from" : "2015-01-01 00:00:00",
|
||||
"to" : "now",
|
||||
"gte" : "2015-01-01 00:00:00",
|
||||
"lte" : "now",
|
||||
"boost" : 1.0,
|
||||
"_name" : "my_range"
|
||||
}
|
||||
|
|
|
@ -80,3 +80,7 @@ tasks.named("precommit").configure {
|
|||
dependsOn 'enforceYamlTestConvention', 'enforceApiSpecsConvention'
|
||||
}
|
||||
|
||||
tasks.named("yamlRestCompatTestTransform").configure({ task ->
|
||||
task.skipTest("security/10_forbidden/Test bulk response with invalid credentials", "warning does not exist for compatibility")
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue