Deprecate template query.

Closes #19390
This commit is contained in:
Martijn van Groningen 2016-07-26 20:05:47 +02:00
parent 3f344d3154
commit 2fdf79d8d4
2 changed files with 13 additions and 1 deletions

View File

@ -310,3 +310,8 @@ transportClient.addTransportAddress(
Also the helper methods in `QueryBuilders` class that create a `TemplateQueryBuilder` instance have been removed,
instead the constructors on `TemplateQueryBuilder` should be used.
==== Template query
The `template` query has been deprecated in favour of the search template api. The `template` query is scheduled
to be removed in the next major version.

View File

@ -23,6 +23,8 @@ import org.elasticsearch.common.ParsingException;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentParser;
@ -47,8 +49,12 @@ import java.util.Optional;
/**
* Facilitates creating template query requests.
* */
@Deprecated
// TODO remove this class in 6.0
public class TemplateQueryBuilder extends AbstractQueryBuilder<TemplateQueryBuilder> {
public static final String NAME = "template";
private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(Loggers.getLogger(TemplateQueryBuilder.class));
/** Template to fill. */
private final Script template;
@ -63,6 +69,7 @@ public class TemplateQueryBuilder extends AbstractQueryBuilder<TemplateQueryBuil
// for tests, so that mock script can be used:
TemplateQueryBuilder(Script template) {
DEPRECATION_LOGGER.deprecated("[{}] query is deprecated, use search template api instead", NAME);
if (template == null) {
throw new IllegalArgumentException("query template cannot be null");
}