From 120b9d9c73c2e18b2e07f7dc20d20300342fecbe Mon Sep 17 00:00:00 2001 From: pgomulka Date: Fri, 14 May 2021 19:06:41 +0200 Subject: [PATCH] [Rest Api Compatibility] REST Terms vector typed response enabeling the tests and adds a type field for termvector response the commit that enabled typed enpoints but missed to update the response https://github.com/elastic/elasticsearch/pull/72155 --- rest-api-spec/build.gradle | 9 +++------ .../action/termvectors/TermVectorsResponse.java | 4 ++++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/rest-api-spec/build.gradle b/rest-api-spec/build.gradle index 52ed8537095e0..fdd38cc63cf9d 100644 --- a/rest-api-spec/build.gradle +++ b/rest-api-spec/build.gradle @@ -119,7 +119,9 @@ tasks.named("yamlRestCompatTest").configure { // there is a small distinction between empty mappings and no mappings at all. The code to implement this test was refactored #54003 // field search on _type field- not implementing. The data for _type is considered incorrect in this search 'search/160_exists_query/Test exists query on _type field', - // 83 - 12 = 71 tests won't be fixed + //type information is not stored, hence the the index will be found + 'termvectors/50_mix_typeless_typeful/Term vectors with typeless API on an index that has types', + // 85 - 13 = 72 tests won't be fixed 'bulk/11_basic_with_types/Array of objects', 'bulk/11_basic_with_types/Empty _id', 'bulk/11_basic_with_types/Empty _id with op_type create', @@ -219,11 +221,6 @@ tasks.named("yamlRestCompatTest").configure { 'snapshot.get/10_basic/Get snapshot info with metadata', 'snapshot.get/10_basic/Get snapshot info with index details', 'suggest/20_completion/Suggestions with source should work', - 'termvectors/11_basic_with_types/Basic tests for termvector get', - 'termvectors/20_issue7121/Term vector API should return \'found: false\' for docs between index and refresh', - 'termvectors/21_issue7121_with_types/Term vector API should return \'found: false\' for docs between index and refresh', - 'termvectors/31_realtime_with_types/Realtime Term Vectors', - 'termvectors/50_mix_typeless_typeful/Term vectors with typeless API on an index that has types' ].join(',') } diff --git a/server/src/main/java/org/elasticsearch/action/termvectors/TermVectorsResponse.java b/server/src/main/java/org/elasticsearch/action/termvectors/TermVectorsResponse.java index 80396184bb6fb..fbdd86914eb29 100644 --- a/server/src/main/java/org/elasticsearch/action/termvectors/TermVectorsResponse.java +++ b/server/src/main/java/org/elasticsearch/action/termvectors/TermVectorsResponse.java @@ -19,6 +19,7 @@ import org.elasticsearch.Version; import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.termvectors.TermVectorsRequest.Flag; +import org.elasticsearch.common.RestApiVersion; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.io.stream.BytesStreamOutput; @@ -170,6 +171,9 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws if (isArtificial() == false) { builder.field(FieldStrings._ID, id); } + if(builder.getRestApiVersion() == RestApiVersion.V_7) { + builder.field(MapperService.TYPE_FIELD_NAME, MapperService.SINGLE_MAPPING_NAME); + } builder.field(FieldStrings._VERSION, docVersion); builder.field(FieldStrings.FOUND, isExists()); builder.field(FieldStrings.TOOK, tookInMillis);