Skip to content

Commit 452a4d2

Browse files
authored
Remove version dependent logic from CompletionFieldMapper (elastic#113011)
We have version based logic that applies the limit to number of completion contexts only to indices created from 8.0 on. Those are the only indices we can now have in a cluster, hence we can remove the version based conditional. Relates to elastic#38675
1 parent d0802e2 commit 452a4d2

File tree

1 file changed

+3
-23
lines changed

1 file changed

+3
-23
lines changed

server/src/main/java/org/elasticsearch/index/mapper/CompletionFieldMapper.java

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@
1919
import org.apache.lucene.search.suggest.document.RegexCompletionQuery;
2020
import org.apache.lucene.search.suggest.document.SuggestField;
2121
import org.elasticsearch.common.ParsingException;
22-
import org.elasticsearch.common.logging.DeprecationCategory;
2322
import org.elasticsearch.common.logging.DeprecationLogger;
2423
import org.elasticsearch.common.unit.Fuzziness;
2524
import org.elasticsearch.common.util.Maps;
2625
import org.elasticsearch.index.IndexVersion;
27-
import org.elasticsearch.index.IndexVersions;
2826
import org.elasticsearch.index.analysis.AnalyzerScope;
2927
import org.elasticsearch.index.analysis.NamedAnalyzer;
3028
import org.elasticsearch.index.query.SearchExecutionContext;
@@ -213,29 +211,11 @@ public CompletionFieldMapper build(MapperBuilderContext context) {
213211

214212
private void checkCompletionContextsLimit() {
215213
if (this.contexts.getValue() != null && this.contexts.getValue().size() > COMPLETION_CONTEXTS_LIMIT) {
216-
if (indexVersionCreated.onOrAfter(IndexVersions.V_8_0_0)) {
217-
throw new IllegalArgumentException(
218-
"Limit of completion field contexts [" + COMPLETION_CONTEXTS_LIMIT + "] has been exceeded"
219-
);
220-
} else {
221-
deprecationLogger.warn(
222-
DeprecationCategory.MAPPINGS,
223-
"excessive_completion_contexts",
224-
"You have defined more than ["
225-
+ COMPLETION_CONTEXTS_LIMIT
226-
+ "] completion contexts"
227-
+ " in the mapping for field ["
228-
+ leafName()
229-
+ "]. "
230-
+ "The maximum allowed number of completion contexts in a mapping will be limited to "
231-
+ "["
232-
+ COMPLETION_CONTEXTS_LIMIT
233-
+ "] starting in version [8.0]."
234-
);
235-
}
214+
throw new IllegalArgumentException(
215+
"Limit of completion field contexts [" + COMPLETION_CONTEXTS_LIMIT + "] has been exceeded"
216+
);
236217
}
237218
}
238-
239219
}
240220

241221
public static final Set<String> ALLOWED_CONTENT_FIELD_NAMES = Set.of(

0 commit comments

Comments
 (0)