diff --git a/modules/mapper-extras/src/yamlRestTest/resources/rest-api-spec/test/search-as-you-type/20_highlighting_field_match_only_text.yml b/modules/mapper-extras/src/yamlRestTest/resources/rest-api-spec/test/search-as-you-type/20_highlighting_field_match_only_text.yml index 19c50b9157f32..306aeb8f5c2f2 100644 --- a/modules/mapper-extras/src/yamlRestTest/resources/rest-api-spec/test/search-as-you-type/20_highlighting_field_match_only_text.yml +++ b/modules/mapper-extras/src/yamlRestTest/resources/rest-api-spec/test/search-as-you-type/20_highlighting_field_match_only_text.yml @@ -1,7 +1,7 @@ setup: - skip: - version: " - 7.1.99" - reason: "added in 7.2.0" + version: " - 2.11.99" + reason: "match_only_text field was introduced in 2.12.0" - do: indices.create: diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.validate_query/20_query_string_field_match_only_text.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.validate_query/20_query_string_field_match_only_text.yml index 18129e1d11861..5387dc8c0bca6 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.validate_query/20_query_string_field_match_only_text.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.validate_query/20_query_string_field_match_only_text.yml @@ -1,5 +1,8 @@ --- "validate_query with query_string parameters": + - skip: + version: " - 2.11.99" + reason: "match_only_text field was introduced in 2.12.0" - do: indices.create: index: test diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/30_sig_terms_field_match_only_text.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/30_sig_terms_field_match_only_text.yml index c75dee019a351..60c59a93ca62a 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/30_sig_terms_field_match_only_text.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/30_sig_terms_field_match_only_text.yml @@ -1,5 +1,8 @@ --- "Default index": + - skip: + version: " - 2.11.99" + reason: "match_only_text field was introduced in 2.12.0" - do: indices.create: index: goodbad @@ -71,84 +74,3 @@ - match: {aggregations.class.buckets.0.sig_terms.buckets.0.key: "bad"} - match: {aggregations.class.buckets.1.sig_terms.buckets.0.key: "good"} - ---- -"IP test": - - do: - indices.create: - index: ip_index - body: - mappings: - properties: - ip: - type: ip - - - do: - index: - index: ip_index - id: 1 - body: { ip: "::1" } - - do: - index: - index: ip_index - id: 2 - body: { } - - - do: - indices.refresh: {} - - - do: - search: - rest_total_hits_as_int: true - body: { "query" : { "exists" : { "field" : "ip" } }, "aggs" : { "ip_terms" : { "significant_terms" : { "field" : "ip", "min_doc_count" : 1 } } } } - - - match: { hits.total: 1 } - - - length: { aggregations.ip_terms.buckets: 1 } - - - match: { aggregations.ip_terms.buckets.0.key: "::1" } - - - is_false: aggregations.ip_terms.buckets.0.key_as_string - - - match: { aggregations.ip_terms.buckets.0.doc_count: 1 } - - - do: - search: - rest_total_hits_as_int: true - body: { "query" : { "exists" : { "field" : "ip" } }, "aggs" : { "ip_terms" : { "significant_terms" : { "field" : "ip", "min_doc_count" : 1, "include" : [ "::1" ] } } } } - - - match: { hits.total: 1 } - - - length: { aggregations.ip_terms.buckets: 1 } - - - match: { aggregations.ip_terms.buckets.0.key: "::1" } - - - do: - search: - rest_total_hits_as_int: true - body: { "query" : { "exists" : { "field" : "ip" } }, "aggs" : { "ip_terms" : { "significant_terms" : { "field" : "ip", "min_doc_count" : 1, "exclude" : [ "::1" ] } } } } - - - match: { hits.total: 1 } - - - length: { aggregations.ip_terms.buckets: 0 } - - - do: - catch: /Aggregation \[ip_terms\] cannot support regular expression style include\/exclude settings as they can only be applied to string fields\. Use an array of values for include\/exclude clauses/ - search: - rest_total_hits_as_int: true - body: { "size" : 0, "aggs" : { "ip_terms" : { "significant_terms" : { "field" : "ip", "exclude" : "127.*" } } } } - ---- -'Misspelled fields get "did you mean"': - - skip: - version: " - 7.6.99" - reason: Implemented in 8.0 (to be backported to 7.7) - - do: - catch: /\[significant_terms\] unknown field \[jlp\] did you mean \[jlh\]\?/ - search: - body: - aggs: - foo: - significant_terms: - field: foo - jlp: {} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/90_sig_text_field_match_only.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/90_sig_text_field_match_only.yml index 873d59907982a..01548df586de6 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/90_sig_text_field_match_only.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/90_sig_text_field_match_only.yml @@ -1,6 +1,8 @@ --- "Default index": - + - skip: + version: " - 2.11.99" + reason: "match_only_text field was introduced in 2.12.0" - do: indices.create: index: goodbad @@ -75,7 +77,9 @@ --- "Dedup noise": - + - skip: + version: " - 2.11.99" + reason: "match_only_text field was introduced in 2.12.0" - do: indices.create: index: goodbad diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/search.inner_hits/20_highlighting_field_match_only_text.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/search.inner_hits/20_highlighting_field_match_only_text.yml index a1b9e7a5506e2..d3fdd87ee3a63 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/search.inner_hits/20_highlighting_field_match_only_text.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/search.inner_hits/20_highlighting_field_match_only_text.yml @@ -1,4 +1,7 @@ setup: + - skip: + version: " - 2.11.99" + reason: "match_only_text field was introduced in 2.12.0" - do: indices.create: index: test diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/search/200_index_phrase_search_field_match_only_text.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/search/200_phrase_search_field_match_only_text.yml similarity index 92% rename from rest-api-spec/src/main/resources/rest-api-spec/test/search/200_index_phrase_search_field_match_only_text.yml rename to rest-api-spec/src/main/resources/rest-api-spec/test/search/200_phrase_search_field_match_only_text.yml index 7c0499de538cf..fa51cd83e62ad 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/search/200_index_phrase_search_field_match_only_text.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/search/200_phrase_search_field_match_only_text.yml @@ -1,5 +1,8 @@ --- "search with indexed phrases": + - skip: + version: " - 2.11.99" + reason: "match_only_text field was introduced in 2.12.0" - do: indices.create: index: test @@ -8,7 +11,6 @@ properties: text: type: match_only_text - index_phrases: true - do: index: diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/search/310_match_bool_prefix_field_match_only_text.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/search/310_match_bool_prefix_field_match_only_text.yml index 3b380bb808245..522a5fe077846 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/search/310_match_bool_prefix_field_match_only_text.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/search/310_match_bool_prefix_field_match_only_text.yml @@ -1,7 +1,7 @@ setup: - skip: - version: " - 7.1.99" - reason: "added in 7.2.0" + version: " - 2.11.99" + reason: "match_only_text field was introduced in 2.12.0" - do: indices.create: diff --git a/server/src/main/java/org/opensearch/index/mapper/MatchOnlyTextFieldMapper.java b/server/src/main/java/org/opensearch/index/mapper/MatchOnlyTextFieldMapper.java index 6b5055d07fd39..ef35a0592a897 100644 --- a/server/src/main/java/org/opensearch/index/mapper/MatchOnlyTextFieldMapper.java +++ b/server/src/main/java/org/opensearch/index/mapper/MatchOnlyTextFieldMapper.java @@ -22,7 +22,6 @@ import org.apache.lucene.search.TermQuery; import org.opensearch.Version; import org.opensearch.common.lucene.search.MultiPhrasePrefixQuery; -import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.index.analysis.IndexAnalyzers; import org.opensearch.index.analysis.NamedAnalyzer; import org.opensearch.index.query.QueryShardContext; @@ -308,30 +307,4 @@ private List> getTermsFromTokenStream(TokenStream stream) throws IOEx return termArray; } } - - @Override - protected void doXContentBody(XContentBuilder builder, boolean includeDefaults, Params params) throws IOException { - // this is a pain, but we have to do this to maintain BWC - builder.field("type", contentType()); - Builder mapperBuilder = (MatchOnlyTextFieldMapper.Builder) getMergeBuilder(); - mapperBuilder.boost.toXContent(builder, includeDefaults); - mapperBuilder.index.toXContent(builder, includeDefaults); - mapperBuilder.store.toXContent(builder, includeDefaults); - this.multiFields.toXContent(builder, params); - this.copyTo.toXContent(builder, params); - mapperBuilder.meta.toXContent(builder, includeDefaults); - mapperBuilder.indexOptions.toXContent(builder, includeDefaults); - mapperBuilder.termVectors.toXContent(builder, includeDefaults); - mapperBuilder.norms.toXContent(builder, includeDefaults); - mapperBuilder.analyzers.indexAnalyzer.toXContent(builder, includeDefaults); - mapperBuilder.analyzers.searchAnalyzer.toXContent(builder, includeDefaults); - mapperBuilder.analyzers.searchQuoteAnalyzer.toXContent(builder, includeDefaults); - mapperBuilder.similarity.toXContent(builder, includeDefaults); - mapperBuilder.eagerGlobalOrdinals.toXContent(builder, includeDefaults); - mapperBuilder.positionIncrementGap.toXContent(builder, includeDefaults); - mapperBuilder.fieldData.toXContent(builder, includeDefaults); - mapperBuilder.freqFilter.toXContent(builder, includeDefaults); - mapperBuilder.indexPrefixes.toXContent(builder, includeDefaults); - mapperBuilder.indexPhrases.toXContent(builder, includeDefaults); - } } diff --git a/server/src/main/java/org/opensearch/index/query/SourceFieldMatchQuery.java b/server/src/main/java/org/opensearch/index/query/SourceFieldMatchQuery.java index 6c1b87a810d0f..4e9a74a92498a 100644 --- a/server/src/main/java/org/opensearch/index/query/SourceFieldMatchQuery.java +++ b/server/src/main/java/org/opensearch/index/query/SourceFieldMatchQuery.java @@ -45,7 +45,7 @@ public class SourceFieldMatchQuery extends Query { * Constructs a SourceFieldMatchQuery. * * @param delegateQuery The parent query to use to find matches. - * @param filter The query used to filter further by running against field value computed using _source field. + * @param filter The query used to filter further by running against field value fetched using _source field. * @param fieldType The mapped field type. * @param context The QueryShardContext to get lookup and valueFetcher */ diff --git a/server/src/test/java/org/opensearch/index/mapper/MatchOnlyTextFieldMapperTests.java b/server/src/test/java/org/opensearch/index/mapper/MatchOnlyTextFieldMapperTests.java index bf39677c0ea14..36aee352732d2 100644 --- a/server/src/test/java/org/opensearch/index/mapper/MatchOnlyTextFieldMapperTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/MatchOnlyTextFieldMapperTests.java @@ -166,6 +166,9 @@ public void testPositionIncrementGap() throws IOException {} @Override public void testDefaultPositionIncrementGap() throws IOException {} + @Override + public void testMinimalToMaximal() throws IOException {} + @Override public void testIndexPrefixMapping() throws IOException { MapperParsingException e = expectThrows( diff --git a/server/src/test/java/org/opensearch/index/query/SourceFieldMatchQueryTests.java b/server/src/test/java/org/opensearch/index/query/SourceFieldMatchQueryTests.java index f3d8ec05ed414..dc98b2f4faf1c 100644 --- a/server/src/test/java/org/opensearch/index/query/SourceFieldMatchQueryTests.java +++ b/server/src/test/java/org/opensearch/index/query/SourceFieldMatchQueryTests.java @@ -38,7 +38,6 @@ public void testAllPossibleScenarios() throws IOException { QueryShardContext queryShardContext = createQueryShardContext(mapperService); when(queryShardContext.sourcePath("desert")).thenReturn(Set.of("desert")); when(queryShardContext.index()).thenReturn(new Index("test_index", "uuid")); - when(queryShardContext.documentMapper(anyString())).thenReturn(mapperService.documentMapper()); String[] deserts = new String[] { "apple pie pie", "banana split pie", "chocolate cake" }; List docs = new ArrayList<>(); @@ -113,7 +112,6 @@ public void testSourceDisabled() throws IOException { QueryShardContext queryShardContext = createQueryShardContext(mapperService); when(queryShardContext.sourcePath("desert")).thenReturn(Set.of("desert")); when(queryShardContext.index()).thenReturn(new Index("test_index", "uuid")); - when(queryShardContext.documentMapper(anyString())).thenReturn(mapperService.documentMapper()); IllegalArgumentException e = expectThrows( IllegalArgumentException.class, () -> new SourceFieldMatchQuery( @@ -141,7 +139,6 @@ public void testMissingField() throws IOException { QueryShardContext queryShardContext = createQueryShardContext(mapperService); when(queryShardContext.sourcePath("desert")).thenReturn(Set.of("desert")); when(queryShardContext.index()).thenReturn(new Index("test_index", "uuid")); - when(queryShardContext.documentMapper(anyString())).thenReturn(mapperService.documentMapper()); String[] deserts = new String[] { "apple pie pie", "banana split pie", "chocolate cake" }; List docs = new ArrayList<>(); diff --git a/test/framework/src/main/java/org/opensearch/index/mapper/MapperServiceTestCase.java b/test/framework/src/main/java/org/opensearch/index/mapper/MapperServiceTestCase.java index c2aa3c2436363..ac78a0d1936ea 100644 --- a/test/framework/src/main/java/org/opensearch/index/mapper/MapperServiceTestCase.java +++ b/test/framework/src/main/java/org/opensearch/index/mapper/MapperServiceTestCase.java @@ -255,6 +255,7 @@ protected QueryShardContext createQueryShardContext(MapperService mapperService) throw new UnsupportedOperationException("search lookup not available"); })); when(queryShardContext.getFieldType(any())).thenAnswer(inv -> mapperService.fieldType(inv.getArguments()[0].toString())); + when(queryShardContext.documentMapper(anyString())).thenReturn(mapperService.documentMapper()); return queryShardContext; } }