diff --git a/docs/reference/mapping/mapping-settings-limit.asciidoc b/docs/reference/mapping/mapping-settings-limit.asciidoc index 9099b3029a7f2..bdde5ca744936 100644 --- a/docs/reference/mapping/mapping-settings-limit.asciidoc +++ b/docs/reference/mapping/mapping-settings-limit.asciidoc @@ -14,7 +14,7 @@ especially in clusters with a high load or few resources. If you increase this setting, we recommend you also increase the <> setting, which -limits the maximum number of <> in a query. +limits the maximum number of clauses in a query. ==== + [TIP] diff --git a/docs/reference/migration/migrate_8_0/search.asciidoc b/docs/reference/migration/migrate_8_0/search.asciidoc index 14e5063fd1118..37cb0db6fbaa3 100644 --- a/docs/reference/migration/migrate_8_0/search.asciidoc +++ b/docs/reference/migration/migrate_8_0/search.asciidoc @@ -20,6 +20,22 @@ Aggregating and sorting on `_id` should be avoided. As an alternative, the `_id` field's contents can be duplicated into another field with docvalues enabled (note that this does not apply to auto-generated IDs). ==== + +[[max_clause_count_change]] +.The `indices.query.bool.max_clause_count` setting now limits all query clauses. +[%collapsible] +==== +*Details* + +Previously, the `indices.query.bool.max_clause_count` would apply to the number +of clauses of a single `bool` query. It now applies to the total number of +clauses of the rewritten query. In order to reduce chances of breaks, its +default value has been bumped from 1024 to 4096. + +*Impact* + +Queries with many clauses should be avoided whenever possible. If you had bumped +this setting already in order to accomodate for some heavy queries, you might +need to bump it further so that these heavy queries keep working. +==== //end::notable-breaking-changes[] .Search-related REST API endpoints containing mapping types have been removed. diff --git a/docs/reference/modules/indices/search-settings.asciidoc b/docs/reference/modules/indices/search-settings.asciidoc index 85eaa88950668..329b27aa273fe 100644 --- a/docs/reference/modules/indices/search-settings.asciidoc +++ b/docs/reference/modules/indices/search-settings.asciidoc @@ -7,16 +7,22 @@ limits. [[indices-query-bool-max-clause-count]] `indices.query.bool.max_clause_count`:: (<>, integer) -Maximum number of clauses a Lucene BooleanQuery can contain. Defaults to `1024`. +Maximum number of clauses a query can contain. Defaults to `4096`. + -This setting limits the number of clauses a Lucene BooleanQuery can have. The -default of 1024 is quite high and should normally be sufficient. This limit does -not only affect Elasticsearchs `bool` query, but many other queries are rewritten to Lucene's -BooleanQuery internally. The limit is in place to prevent searches from becoming too large -and taking up too much CPU and memory. In case you're considering increasing this setting, -make sure you've exhausted all other options to avoid having to do this. Higher values can lead -to performance degradations and memory issues, especially in clusters with a high load or -few resources. +This setting limits the total number of clauses that a query tree can have. The default of 4096 +is quite high and should normally be sufficient. This limit applies to the rewritten query, so +not only `bool` queries can contribute high numbers of clauses, but also all queries that rewrite +to `bool` queries internally such as `fuzzy` queries. The limit is in place to prevent searches +from becoming too large, and taking up too much CPU and memory. In case you're considering +increasing this setting, make sure you've exhausted all other options to avoid having to do this. +Higher values can lead to performance degradations and memory issues, especially in clusters with +a high load or few resources. + +Elasticsearch offers some tools to avoid running into issues with regards to the maximum number of +clauses such as the <> query, which allows querying many distinct +values while still counting as a single clause, or the <> option +of <> fields, which allows executing prefix queries that expand to a high +number of terms as a single term query. [[search-settings-max-buckets]] `search.max_buckets`:: diff --git a/docs/reference/query-dsl/combined-fields-query.asciidoc b/docs/reference/query-dsl/combined-fields-query.asciidoc index 390d71276cf3d..42d1f45b0368b 100644 --- a/docs/reference/query-dsl/combined-fields-query.asciidoc +++ b/docs/reference/query-dsl/combined-fields-query.asciidoc @@ -37,9 +37,9 @@ model perfectly.) [WARNING] .Field number limit =================================================== -There is a limit on the number of fields that can be queried at once. It is -defined by the `indices.query.bool.max_clause_count` <> -which defaults to 1024. +There is a limit on the number of fields times terms that can be queried at +once. It is defined by the `indices.query.bool.max_clause_count` +<> which defaults to 4096. =================================================== ==== Per-field boosting diff --git a/docs/reference/query-dsl/multi-match-query.asciidoc b/docs/reference/query-dsl/multi-match-query.asciidoc index d155e5a05c1a9..0b38b25ad80e1 100644 --- a/docs/reference/query-dsl/multi-match-query.asciidoc +++ b/docs/reference/query-dsl/multi-match-query.asciidoc @@ -67,9 +67,9 @@ index settings, which in turn defaults to `*`. `*` extracts all fields in the ma are eligible to term queries and filters the metadata fields. All extracted fields are then combined to build a query. -WARNING: There is a limit on the number of fields that can be queried +WARNING: There is a limit on the number of fields times terms that can be queried at once. It is defined by the `indices.query.bool.max_clause_count` <> -which defaults to 1024. +which defaults to 4096. [[multi-match-types]] [discrete] diff --git a/docs/reference/query-dsl/query-string-query.asciidoc b/docs/reference/query-dsl/query-string-query.asciidoc index 52a2992a90d2c..e0f707a3f5869 100644 --- a/docs/reference/query-dsl/query-string-query.asciidoc +++ b/docs/reference/query-dsl/query-string-query.asciidoc @@ -77,9 +77,9 @@ documents. For mappings with a large number of fields, searching across all eligible fields could be expensive. -There is a limit on the number of fields that can be queried at once. +There is a limit on the number of fields times terms that can be queried at once. It is defined by the `indices.query.bool.max_clause_count` -<>, which defaults to 1024. +<>, which defaults to 4096. ==== -- diff --git a/docs/reference/query-dsl/span-multi-term-query.asciidoc b/docs/reference/query-dsl/span-multi-term-query.asciidoc index 8a78c2ba19705..aefb3e4b75eb5 100644 --- a/docs/reference/query-dsl/span-multi-term-query.asciidoc +++ b/docs/reference/query-dsl/span-multi-term-query.asciidoc @@ -39,7 +39,7 @@ GET /_search -------------------------------------------------- WARNING: `span_multi` queries will hit too many clauses failure if the number of terms that match the query exceeds the -boolean query limit (defaults to 1024).To avoid an unbounded expansion you can set the <> of the multi term query to `top_terms_*` rewrite. Or, if you use `span_multi` on `prefix` query only, you can activate the <> field option of the `text` field instead. This will rewrite any prefix query on the field to a single term query that matches the indexed prefix. diff --git a/server/src/main/java/org/elasticsearch/search/SearchModule.java b/server/src/main/java/org/elasticsearch/search/SearchModule.java index 927e0e42544a5..4f35bf10c94bb 100644 --- a/server/src/main/java/org/elasticsearch/search/SearchModule.java +++ b/server/src/main/java/org/elasticsearch/search/SearchModule.java @@ -263,7 +263,7 @@ */ public class SearchModule { public static final Setting INDICES_MAX_CLAUSE_COUNT_SETTING = Setting.intSetting("indices.query.bool.max_clause_count", - 1024, 1, Integer.MAX_VALUE, Setting.Property.NodeScope); + 4096, 1, Integer.MAX_VALUE, Setting.Property.NodeScope); public static final Setting INDICES_MAX_NESTED_DEPTH_SETTING = Setting.intSetting("indices.query.bool.max_nested_depth", 20, 1, Integer.MAX_VALUE, Setting.Property.NodeScope);