|
24 | 24 | import org.elasticsearch.common.bytes.BytesReference;
|
25 | 25 | import org.elasticsearch.common.io.stream.StreamInput;
|
26 | 26 | import org.elasticsearch.common.io.stream.StreamOutput;
|
27 |
| -import org.elasticsearch.common.logging.DeprecationLogger; |
28 |
| -import org.elasticsearch.common.logging.Loggers; |
29 | 27 | import org.elasticsearch.common.unit.Fuzziness;
|
30 | 28 | import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
|
31 | 29 | import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
|
60 | 58 | */
|
61 | 59 | public class CompletionSuggestionBuilder extends SuggestionBuilder<CompletionSuggestionBuilder> {
|
62 | 60 |
|
63 |
| - private static final DeprecationLogger DEPRECATION_LOGGER = |
64 |
| - new DeprecationLogger(Loggers.getLogger(CompletionSuggestionBuilder.class)); |
65 |
| - |
66 | 61 | private static final XContentType CONTEXT_BYTES_XCONTENT_TYPE = XContentType.JSON;
|
67 | 62 | static final String SUGGESTION_NAME = "completion";
|
68 | 63 | static final ParseField CONTEXTS_FIELD = new ParseField("contexts", "context");
|
@@ -304,19 +299,16 @@ public SuggestionContext build(QueryShardContext context) throws IOException {
|
304 | 299 | if (mappedFieldType == null || mappedFieldType instanceof CompletionFieldMapper.CompletionFieldType == false) {
|
305 | 300 | throw new IllegalArgumentException("Field [" + suggestionContext.getField() + "] is not a completion suggest field");
|
306 | 301 | }
|
307 |
| - CompletionFieldMapper.CompletionFieldType type = (CompletionFieldMapper.CompletionFieldType) mappedFieldType; |
308 |
| - suggestionContext.setFieldType(type); |
309 |
| - if (type.hasContextMappings()) { |
310 |
| - if (contextBytes == null) { |
311 |
| - DEPRECATION_LOGGER.deprecated("The ability to query with no context on a context enabled completion field is deprecated " + |
312 |
| - "and will be removed in the next major release."); |
313 |
| - } else { |
| 302 | + if (mappedFieldType instanceof CompletionFieldMapper.CompletionFieldType) { |
| 303 | + CompletionFieldMapper.CompletionFieldType type = (CompletionFieldMapper.CompletionFieldType) mappedFieldType; |
| 304 | + suggestionContext.setFieldType(type); |
| 305 | + if (type.hasContextMappings() && contextBytes != null) { |
314 | 306 | Map<String, List<ContextMapping.InternalQueryContext>> queryContexts = parseContextBytes(contextBytes,
|
315 |
| - context.getXContentRegistry(), type.getContextMappings()); |
| 307 | + context.getXContentRegistry(), type.getContextMappings()); |
316 | 308 | suggestionContext.setQueryContexts(queryContexts);
|
| 309 | + } else if (contextBytes != null) { |
| 310 | + throw new IllegalArgumentException("suggester [" + type.name() + "] doesn't expect any context"); |
317 | 311 | }
|
318 |
| - } else if (contextBytes != null) { |
319 |
| - throw new IllegalArgumentException("suggester [" + type.name() + "] doesn't expect any context"); |
320 | 312 | }
|
321 | 313 | assert suggestionContext.getFieldType() != null : "no completion field type set";
|
322 | 314 | return suggestionContext;
|
|
0 commit comments