|
12 | 12 | import org.elasticsearch.cluster.metadata.IndexMetadata; |
13 | 13 | import org.elasticsearch.cluster.metadata.MappingMetadata; |
14 | 14 | import org.elasticsearch.cluster.routing.allocation.DataTier; |
15 | | -import org.elasticsearch.common.Strings; |
16 | 15 | import org.elasticsearch.common.bytes.BytesReference; |
17 | 16 | import org.elasticsearch.common.settings.Settings; |
18 | 17 | import org.elasticsearch.index.IndexModule; |
|
41 | 40 | import java.util.stream.Stream; |
42 | 41 |
|
43 | 42 | import static java.util.Collections.singletonList; |
44 | | -import static org.elasticsearch.xcontent.XContentFactory.jsonBuilder; |
45 | 43 | import static org.elasticsearch.xpack.cluster.routing.allocation.DataTierAllocationDecider.INDEX_ROUTING_EXCLUDE_SETTING; |
46 | 44 | import static org.elasticsearch.xpack.cluster.routing.allocation.DataTierAllocationDecider.INDEX_ROUTING_INCLUDE_SETTING; |
47 | 45 | import static org.elasticsearch.xpack.cluster.routing.allocation.DataTierAllocationDecider.INDEX_ROUTING_REQUIRE_SETTING; |
@@ -83,87 +81,6 @@ public void testOldIndicesCheck() { |
83 | 81 | assertEquals(singletonList(expected), issues); |
84 | 82 | } |
85 | 83 |
|
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 | | - |
167 | 84 | public void testChainedMultiFields() throws IOException { |
168 | 85 | XContentBuilder xContent = XContentFactory.jsonBuilder(); |
169 | 86 | xContent.startObject(); |
|
0 commit comments