From 35c36b935eae379e3a77c589c46261d1c88bfb98 Mon Sep 17 00:00:00 2001 From: Kathleen DeRusso Date: Wed, 16 Oct 2024 16:41:06 -0400 Subject: [PATCH] Spotless again --- .../rules/80_query_rules_retriever.yml | 88 ++++++++++++++++++- .../TextSimilarityRankRetrieverBuilder.java | 2 - 2 files changed, 86 insertions(+), 4 deletions(-) diff --git a/x-pack/plugin/ent-search/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/entsearch/rules/80_query_rules_retriever.yml b/x-pack/plugin/ent-search/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/entsearch/rules/80_query_rules_retriever.yml index 1d50949d4cf0d..7127363a8c979 100644 --- a/x-pack/plugin/ent-search/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/entsearch/rules/80_query_rules_retriever.yml +++ b/x-pack/plugin/ent-search/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/entsearch/rules/80_query_rules_retriever.yml @@ -27,8 +27,92 @@ setup: _id: baz - { "text": "baz - no rule attached" } - index: - _id: bar2 - - { "text": "bar2 - no rule attached" } + _id: foo_no_rule + - { "text": "text search result for foo with no rule attached" } + - index: + _id: bar_no_rule + - { "text": "text search result for bar with no rule attached" } - index: _id: foo2 - { "text": "foo2 - second pinned doc for foo" } + + - do: + query_rules.put_ruleset: + ruleset_id: test-ruleset + body: + rules: + - rule_id: foo + type: pinned + criteria: + - type: exact + metadata: foo + values: [ foo ] + actions: + ids: + - foo + - foo2 + - rule_id: bar + type: exclude + criteria: + - type: exact + metadata: bar + values: [ bar ] + actions: + ids: + - bar + +--- +"standalone query rules retriever": + + - do: + search: + index: test + body: + retriever: + rule: + match:criteria: + foo: foo + bar: bar + ruleset_ids: + test-ruleset + retriever: + standard: + query: + query_string: + query: bar + + - match: { hits.hits.size: 3 } + - match: { hits.hits.0._id: foo } + - match: { hits.hits.1._id: foo2 } + - match: { hits.hits.2._id: bar_no_rule } + +--- +"query rules retriever combined with rrf": + + - do: + search: + index: test + body: + retriever: + rule: + match:criteria: + foo: foo + bar: bar + ruleset_ids: + test-ruleset + retriever: + rrf: + retrievers: [ + { + + }, + { + + } + ] + + - match: { hits.hits.size: 3 } + - match: { hits.hits.0._id: foo } + - match: { hits.hits.1._id: foo2 } + - match: { hits.hits.2._id: bar_no_rule } + diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/rank/textsimilarity/TextSimilarityRankRetrieverBuilder.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/rank/textsimilarity/TextSimilarityRankRetrieverBuilder.java index fc78cb8889e83..02603edbc7819 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/rank/textsimilarity/TextSimilarityRankRetrieverBuilder.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/rank/textsimilarity/TextSimilarityRankRetrieverBuilder.java @@ -10,7 +10,6 @@ import org.apache.lucene.search.ScoreDoc; import org.elasticsearch.common.ParsingException; import org.elasticsearch.features.NodeFeature; -import org.elasticsearch.index.query.BoolQueryBuilder; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.license.LicenseUtils; import org.elasticsearch.search.builder.PointInTimeBuilder; @@ -20,7 +19,6 @@ import org.elasticsearch.search.retriever.CompoundRetrieverBuilder; import org.elasticsearch.search.retriever.RetrieverBuilder; import org.elasticsearch.search.retriever.RetrieverParserContext; -import org.elasticsearch.search.retriever.rankdoc.RankDocsQueryBuilder; import org.elasticsearch.xcontent.ConstructingObjectParser; import org.elasticsearch.xcontent.ParseField; import org.elasticsearch.xcontent.XContentBuilder;