From e0286e9bd3021d2fc190aed77b1da50da7b4926e Mon Sep 17 00:00:00 2001 From: markharwood Date: Tue, 28 Jul 2020 17:12:33 +0100 Subject: [PATCH] Search - remove allow-expensive-query checks from wildcard field. (#60273) (#60308) Removing allow-expensive-query checks because we think this field type is fast enough. Closes #60139 --- docs/reference/query-dsl.asciidoc | 10 +++++----- .../xpack/wildcard/mapper/WildcardFieldMapper.java | 12 ------------ 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/docs/reference/query-dsl.asciidoc b/docs/reference/query-dsl.asciidoc index 51889a5f2c1..3313ef76684 100644 --- a/docs/reference/query-dsl.asciidoc +++ b/docs/reference/query-dsl.asciidoc @@ -32,11 +32,11 @@ Certain types of queries will generally execute slowly due to the way they are i the stability of the cluster. Those queries can be categorised as follows: * Queries that need to do linear scans to identify matches: ** <> -* Queries that have a high up-front cost: -** <> -** <> -** <> without <> -** <> +* Queries that have a high up-front cost : +** <> (except on <> fields) +** <> (except on <> fields) +** <> (except on <> fields or those without <>) +** <> (except on <> fields) ** <> on <> and <> fields * <> * Queries on <> diff --git a/x-pack/plugin/wildcard/src/main/java/org/elasticsearch/xpack/wildcard/mapper/WildcardFieldMapper.java b/x-pack/plugin/wildcard/src/main/java/org/elasticsearch/xpack/wildcard/mapper/WildcardFieldMapper.java index 470dc4b9d2e..5694ab0e041 100644 --- a/x-pack/plugin/wildcard/src/main/java/org/elasticsearch/xpack/wildcard/mapper/WildcardFieldMapper.java +++ b/x-pack/plugin/wildcard/src/main/java/org/elasticsearch/xpack/wildcard/mapper/WildcardFieldMapper.java @@ -36,7 +36,6 @@ import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.automaton.Automaton; import org.apache.lucene.util.automaton.RegExp; import org.apache.lucene.util.automaton.RegExp.Kind; -import org.elasticsearch.ElasticsearchException; import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.common.geo.ShapeRelation; import org.elasticsearch.common.lucene.BytesRefs; @@ -79,7 +78,6 @@ import java.util.Set; import java.util.function.Supplier; import static org.elasticsearch.index.mapper.TypeParsers.parseField; -import static org.elasticsearch.search.SearchService.ALLOW_EXPENSIVE_QUERIES; /** * A {@link FieldMapper} for indexing fields with ngrams for efficient wildcard matching @@ -299,12 +297,6 @@ public class WildcardFieldMapper extends FieldMapper { return new MatchNoDocsQuery(); } - if (context.allowExpensiveQueries() == false) { - throw new ElasticsearchException( - "[regexp] queries cannot be executed when '" + ALLOW_EXPENSIVE_QUERIES.getKey() + "' is set to false." - ); - } - RegExp ngramRegex = new RegExp(addLineEndChars(toLowerCase(value)), flags); Query approxBooleanQuery = toApproximationQuery(ngramRegex); @@ -670,10 +662,6 @@ public class WildcardFieldMapper extends FieldMapper { DateMathParser parser, QueryShardContext context ) { - if (context.allowExpensiveQueries() == false) { - throw new ElasticsearchException("[range] queries on [wildcard] fields cannot be executed when '" + - ALLOW_EXPENSIVE_QUERIES.getKey() + "' is set to false."); - } BytesRef lower = lowerTerm == null ? null : BytesRefs.toBytesRef(lowerTerm); BytesRef upper = upperTerm == null ? null : BytesRefs.toBytesRef(upperTerm); Query accelerationQuery = null;