Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions rest-api-spec/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,11 @@ tasks.named("yamlRestCompatTest").configure {
'indices.open/10_basic/?wait_for_active_shards=index-setting',
// not fixing this in #70966
'indices.put_template/11_basic_with_types/Put template with empty mappings',
'mlt/20_docs/Basic mlt query with docs',
'mlt/30_unlike/Basic mlt query with unlike',
'search.aggregation/200_top_hits_metric/top_hits aggregation with sequence numbers',
'search.aggregation/20_terms/*profiler*', // The profiler results aren't backwards compatible.
'search.aggregation/51_filter_with_types/Filter aggs with terms lookup and ensure it\'s cached',
'search.aggregation/370_doc_count_field/Test filters agg with doc_count', // Uses profiler for assertions which is not backwards compatible
'mtermvectors/11_basic_with_types/Basic tests for multi termvector get',
'mtermvectors/21_deprecated_with_types/Deprecated camel case and _ parameters should fail in Term Vectors query',
'mtermvectors/30_mix_typeless_typeful/mtermvectors without types on an index that has types',
'search/150_rewrite_on_coordinator/Ensure that we fetch the document only once', //terms_lookup
'search/171_terms_query_with_types/Terms Query with No.of terms exceeding index.max_terms_count should FAIL', //bulk
'search/260_parameter_validation/test size=-1 is deprecated', //size=-1 change
'search/310_match_bool_prefix/multi_match multiple fields with cutoff_frequency throws exception', //cutoff_frequency
'search/340_type_query/type query', // type_query - probably should behave like match_all
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.core.RestApiVersion;
import org.elasticsearch.index.mapper.MapperService;

import java.io.IOException;
import java.util.Arrays;
Expand Down Expand Up @@ -112,6 +114,9 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
builder.startObject();
Failure failure = response.getFailure();
builder.field(Fields._INDEX, failure.getIndex());
if (builder.getRestApiVersion() == RestApiVersion.V_7) {
builder.field(Fields._TYPE, MapperService.SINGLE_MAPPING_NAME);
}
builder.field(Fields._ID, failure.getId());
ElasticsearchException.generateFailureXContent(builder, params, failure.getCause(), true);
builder.endObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ private static class FieldStrings {
public static final String END_OFFSET = "end_offset";
public static final String PAYLOAD = "payload";
public static final String _INDEX = "_index";
public static final String _TYPE = "_type";
public static final String _ID = "_id";
public static final String _VERSION = "_version";
public static final String FOUND = "found";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.elasticsearch.action.termvectors.TermVectorsRequest;
import org.elasticsearch.action.termvectors.TermVectorsResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.core.Nullable;
import org.elasticsearch.common.xcontent.ParseField;
import org.elasticsearch.common.ParsingException;
Expand All @@ -40,10 +41,12 @@
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.core.RestApiVersion;
import org.elasticsearch.index.VersionType;
import org.elasticsearch.index.mapper.IdFieldMapper;
import org.elasticsearch.index.mapper.KeywordFieldMapper.KeywordFieldType;
import org.elasticsearch.index.mapper.MappedFieldType;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.index.mapper.TextFieldMapper.TextFieldType;

import java.io.IOException;
Expand All @@ -67,6 +70,10 @@
*/
public class MoreLikeThisQueryBuilder extends AbstractQueryBuilder<MoreLikeThisQueryBuilder> {
public static final String NAME = "more_like_this";
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(MoreLikeThisQueryBuilder.class);
static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Types are deprecated in [more_like_this] " +
"queries. The type should no longer be specified in the [like] and [unlike] sections.";


public static final int DEFAULT_MAX_QUERY_TERMS = XMoreLikeThis.DEFAULT_MAX_QUERY_TERMS;
public static final int DEFAULT_MIN_TERM_FREQ = XMoreLikeThis.DEFAULT_MIN_TERM_FREQ;
Expand Down Expand Up @@ -99,6 +106,7 @@ public class MoreLikeThisQueryBuilder extends AbstractQueryBuilder<MoreLikeThisQ
private static final ParseField FAIL_ON_UNSUPPORTED_FIELD = new ParseField("fail_on_unsupported_field");

private static final ParseField INDEX = new ParseField("_index");
private static final ParseField TYPE = new ParseField("_type");
private static final ParseField ID = new ParseField("_id");
public static final ParseField DOC = new ParseField("doc");
private static final ParseField PER_FIELD_ANALYZER = new ParseField("per_field_analyzer");
Expand Down Expand Up @@ -345,6 +353,9 @@ public static Item parse(XContentParser parser, Item item) throws IOException {
} else if (currentFieldName != null) {
if (INDEX.match(currentFieldName, parser.getDeprecationHandler())) {
item.index = parser.text();
} else if (parser.getRestApiVersion() == RestApiVersion.V_7 &&
TYPE.match(currentFieldName, parser.getDeprecationHandler())) {
deprecationLogger.compatibleApiWarning("more_like_this_query_with_types", TYPES_DEPRECATION_MESSAGE);
} else if (ID.match(currentFieldName, parser.getDeprecationHandler())) {
item.id = parser.text();
} else if (DOC.match(currentFieldName, parser.getDeprecationHandler())) {
Expand Down Expand Up @@ -392,6 +403,9 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
if (this.index != null) {
builder.field(INDEX.getPreferredName(), this.index);
}
if (builder.getRestApiVersion() == RestApiVersion.V_7) {
builder.field(TYPE.getPreferredName(), MapperService.SINGLE_MAPPING_NAME);
}
if (this.id != null) {
builder.field(ID.getPreferredName(), this.id);
}
Expand Down