Skip to content

Commit 520b0a0

Browse files
authored
Remove too_many_fields upgrade check (#82809)
This check issues a warning if the cluster contains an index that has more than 1024 fields, and no default_field set for searching. However, the 1024 boolean clause limit is no longer relevant with #81850, and in any case this isn't something that would have prevented a successful upgrade from 7.17 to 8.0, so we can remove the check entirely. Fixes #81539
1 parent 1704a5f commit 520b0a0

File tree

3 files changed

+0
-117
lines changed

3 files changed

+0
-117
lines changed

x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationChecks.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,6 @@ private static Set<Setting<Boolean>> getAllDeprecatedNodeRolesSettings() {
249249
static List<BiFunction<ClusterState, IndexMetadata, DeprecationIssue>> INDEX_SETTINGS_CHECKS = Collections.unmodifiableList(
250250
Arrays.asList(
251251
(clusterState, indexMetadata) -> IndexDeprecationChecks.oldIndicesCheck(indexMetadata),
252-
(clusterState, indexMetadata) -> IndexDeprecationChecks.tooManyFieldsCheck(indexMetadata),
253252
(clusterState, indexMetadata) -> IndexDeprecationChecks.chainedMultiFieldsCheck(indexMetadata),
254253
(clusterState, indexMetadata) -> IndexDeprecationChecks.chainedMultiFieldsDynamicTemplateCheck(indexMetadata),
255254
(clusterState, indexMetadata) -> IndexDeprecationChecks.boostMappingCheck(indexMetadata),

x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecks.java

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import java.util.Locale;
3535
import java.util.Map;
3636
import java.util.Set;
37-
import java.util.concurrent.atomic.AtomicInteger;
3837
import java.util.function.BiConsumer;
3938
import java.util.function.BiFunction;
4039
import java.util.function.Function;
@@ -193,38 +192,6 @@ static DeprecationIssue oldIndicesCheck(IndexMetadata indexMetadata) {
193192
return null;
194193
}
195194

196-
static DeprecationIssue tooManyFieldsCheck(IndexMetadata indexMetadata) {
197-
if (indexMetadata.getSettings().get(IndexSettings.DEFAULT_FIELD_SETTING.getKey()) == null) {
198-
AtomicInteger fieldCount = new AtomicInteger(0);
199-
200-
fieldLevelMappingIssue(
201-
indexMetadata,
202-
((mappingMetadata, sourceAsMap) -> { fieldCount.addAndGet(countFieldsRecursively(mappingMetadata.type(), sourceAsMap)); })
203-
);
204-
205-
// We can't get to the setting `indices.query.bool.max_clause_count` from here, so just check the default of that setting.
206-
// It's also much better practice to set `index.query.default_field` than `indices.query.bool.max_clause_count` - there's a
207-
// reason we introduced the limit.
208-
if (fieldCount.get() > 1024) {
209-
return new DeprecationIssue(
210-
DeprecationIssue.Level.WARNING,
211-
"Number of fields exceeds automatic field expansion limit",
212-
"https://ela.st/es-deprecation-7-number-of-auto-expanded-fields",
213-
"This index has "
214-
+ fieldCount.get()
215-
+ " fields, which exceeds the automatic field expansion limit (1024). Set "
216-
+ IndexSettings.DEFAULT_FIELD_SETTING.getKey()
217-
+ " to prevent queries that support automatic field expansion from "
218-
+ "failing if no fields are specified. Otherwise, you must explicitly specify fields in all query_string, "
219-
+ "simple_query_string, and multi_match queries.",
220-
false,
221-
null
222-
);
223-
}
224-
}
225-
return null;
226-
}
227-
228195
static DeprecationIssue deprecatedDateTimeFormat(IndexMetadata indexMetadata) {
229196
Version createdWith = indexMetadata.getCreationVersion();
230197
if (createdWith.before(Version.V_7_0_0)) {

x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecksTests.java

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import org.elasticsearch.cluster.metadata.IndexMetadata;
1313
import org.elasticsearch.cluster.metadata.MappingMetadata;
1414
import org.elasticsearch.cluster.routing.allocation.DataTier;
15-
import org.elasticsearch.common.Strings;
1615
import org.elasticsearch.common.bytes.BytesReference;
1716
import org.elasticsearch.common.settings.Settings;
1817
import org.elasticsearch.index.IndexModule;
@@ -41,7 +40,6 @@
4140
import java.util.stream.Stream;
4241

4342
import static java.util.Collections.singletonList;
44-
import static org.elasticsearch.xcontent.XContentFactory.jsonBuilder;
4543
import static org.elasticsearch.xpack.cluster.routing.allocation.DataTierAllocationDecider.INDEX_ROUTING_EXCLUDE_SETTING;
4644
import static org.elasticsearch.xpack.cluster.routing.allocation.DataTierAllocationDecider.INDEX_ROUTING_INCLUDE_SETTING;
4745
import static org.elasticsearch.xpack.cluster.routing.allocation.DataTierAllocationDecider.INDEX_ROUTING_REQUIRE_SETTING;
@@ -83,87 +81,6 @@ public void testOldIndicesCheck() {
8381
assertEquals(singletonList(expected), issues);
8482
}
8583

86-
public void testTooManyFieldsCheck() throws IOException {
87-
String simpleMapping = "{\n"
88-
+ " \"properties\": {\n"
89-
+ " \"some_field\": {\n"
90-
+ " \"type\": \"text\"\n"
91-
+ " },\n"
92-
+ " \"other_field\": {\n"
93-
+ " \"type\": \"text\",\n"
94-
+ " \"properties\": {\n"
95-
+ " \"raw\": {\"type\": \"keyword\"}\n"
96-
+ " }\n"
97-
+ " }\n"
98-
+ " }\n"
99-
+ "}";
100-
101-
IndexMetadata simpleIndex = IndexMetadata.builder(randomAlphaOfLengthBetween(5, 10))
102-
.settings(settings(Version.V_7_0_0))
103-
.numberOfShards(randomIntBetween(1, 100))
104-
.numberOfReplicas(randomIntBetween(1, 100))
105-
.putMapping("_doc", simpleMapping)
106-
.build();
107-
List<DeprecationIssue> noIssues = DeprecationChecks.filterChecks(
108-
INDEX_SETTINGS_CHECKS,
109-
c -> c.apply(ClusterState.EMPTY_STATE, simpleIndex)
110-
);
111-
assertEquals(0, noIssues.size());
112-
113-
// Test that it catches having too many fields
114-
int fieldCount = randomIntBetween(1025, 10_000); // 10_000 is arbitrary
115-
116-
XContentBuilder mappingBuilder = jsonBuilder();
117-
mappingBuilder.startObject();
118-
{
119-
mappingBuilder.startObject("properties");
120-
{
121-
addRandomFields(fieldCount, mappingBuilder);
122-
}
123-
mappingBuilder.endObject();
124-
}
125-
mappingBuilder.endObject();
126-
127-
IndexMetadata tooManyFieldsIndex = IndexMetadata.builder(randomAlphaOfLengthBetween(5, 10))
128-
.settings(settings(Version.V_7_0_0))
129-
.numberOfShards(randomIntBetween(1, 100))
130-
.numberOfReplicas(randomIntBetween(1, 100))
131-
.putMapping("_doc", Strings.toString(mappingBuilder))
132-
.build();
133-
DeprecationIssue expected = new DeprecationIssue(
134-
DeprecationIssue.Level.WARNING,
135-
"Number of fields exceeds automatic field expansion limit",
136-
"https://ela.st/es-deprecation-7-number-of-auto-expanded-fields",
137-
"This index has "
138-
+ fieldCount
139-
+ " fields, which exceeds the automatic field expansion limit (1024). Set "
140-
+ IndexSettings.DEFAULT_FIELD_SETTING.getKey()
141-
+ " to prevent queries that support automatic field expansion from failing "
142-
+ "if no fields are specified. Otherwise, you must explicitly specify fields in all query_string, simple_query_string, and "
143-
+ "multi_match queries.",
144-
false,
145-
null
146-
);
147-
List<DeprecationIssue> issues = DeprecationChecks.filterChecks(
148-
INDEX_SETTINGS_CHECKS,
149-
c -> c.apply(ClusterState.EMPTY_STATE, tooManyFieldsIndex)
150-
);
151-
assertEquals(singletonList(expected), issues);
152-
153-
// Check that it's okay to have too many fields as long as `index.query.default_field` is set
154-
IndexMetadata tooManyFieldsOk = IndexMetadata.builder(randomAlphaOfLengthBetween(5, 10))
155-
.settings(settings(Version.V_7_0_0).put(IndexSettings.DEFAULT_FIELD_SETTING.getKey(), randomAlphaOfLength(5)))
156-
.numberOfShards(randomIntBetween(1, 100))
157-
.numberOfReplicas(randomIntBetween(1, 100))
158-
.putMapping("_doc", Strings.toString(mappingBuilder))
159-
.build();
160-
List<DeprecationIssue> withDefaultFieldIssues = DeprecationChecks.filterChecks(
161-
INDEX_SETTINGS_CHECKS,
162-
c -> c.apply(ClusterState.EMPTY_STATE, tooManyFieldsOk)
163-
);
164-
assertEquals(0, withDefaultFieldIssues.size());
165-
}
166-
16784
public void testChainedMultiFields() throws IOException {
16885
XContentBuilder xContent = XContentFactory.jsonBuilder();
16986
xContent.startObject();

0 commit comments

Comments
 (0)