Skip to content

Commit 042c096

Browse files
committed
Fix: Add NamedWriteable for RuleQueryRankDoc (elastic#128153)
* Add NamedWriteable for QueryRule rank doc * Update test * Update docs/changelog/128153.yaml * Add multi cluster test for query rules * Commenting out code - explicitly trying to spur a test failure * [CI] Auto commit changes from spotless * Streamline test for multi cluster * Revert changes to try to break test * Fix compile error --------- Co-authored-by: elasticsearchmachine <[email protected]> (cherry picked from commit b335c1a) # Conflicts: # x-pack/plugin/ent-search/src/yamlRestTest/resources/rest-api-spec/test/entsearch/rules/40_rule_query_search.yml
1 parent 50c14b8 commit 042c096

File tree

3 files changed

+92
-0
lines changed

3 files changed

+92
-0
lines changed

docs/changelog/128153.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 128153
2+
summary: "Fix: Add `NamedWriteable` for `RuleQueryRankDoc`"
3+
area: Relevance
4+
type: bug
5+
issues:
6+
- 126071

x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/EnterpriseSearch.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.elasticsearch.plugins.SystemIndexPlugin;
3131
import org.elasticsearch.rest.RestController;
3232
import org.elasticsearch.rest.RestHandler;
33+
import org.elasticsearch.search.rank.RankDoc;
3334
import org.elasticsearch.xcontent.ParseField;
3435
import org.elasticsearch.xpack.application.analytics.AnalyticsTemplateRegistry;
3536
import org.elasticsearch.xpack.application.analytics.action.DeleteAnalyticsCollectionAction;
@@ -179,6 +180,7 @@
179180
import org.elasticsearch.xpack.application.rules.action.TransportPutQueryRulesetAction;
180181
import org.elasticsearch.xpack.application.rules.action.TransportTestQueryRulesetAction;
181182
import org.elasticsearch.xpack.application.rules.retriever.QueryRuleRetrieverBuilder;
183+
import org.elasticsearch.xpack.application.rules.retriever.RuleQueryRankDoc;
182184
import org.elasticsearch.xpack.application.search.SearchApplicationIndexService;
183185
import org.elasticsearch.xpack.application.search.action.DeleteSearchApplicationAction;
184186
import org.elasticsearch.xpack.application.search.action.GetSearchApplicationAction;
@@ -351,6 +353,11 @@ protected XPackLicenseState getLicenseState() {
351353
return Collections.unmodifiableList(actionHandlers);
352354
}
353355

356+
@Override
357+
public List<NamedWriteableRegistry.Entry> getNamedWriteables() {
358+
return List.of(new NamedWriteableRegistry.Entry(RankDoc.class, RuleQueryRankDoc.NAME, RuleQueryRankDoc::new));
359+
}
360+
354361
@Override
355362
public List<RestHandler> getRestHandlers(
356363
Settings settings,

x-pack/plugin/ent-search/src/yamlRestTest/resources/rest-api-spec/test/entsearch/rules/40_rule_query_search.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,3 +893,82 @@ teardown:
893893
- match: { hits.total.value: 2 }
894894
- match: { hits.hits.0._id: 'doc1' }
895895
- match: { hits.hits.1._id: 'doc4' }
896+
897+
---
898+
"Multi-index search with missing documents does not error":
899+
- requires:
900+
cluster_features: [ "test_rule_retriever.with_indices_that_dont_return_rank_docs" ]
901+
reason: "Fixed"
902+
903+
- do:
904+
indices.create:
905+
index: test-index-001
906+
body:
907+
settings:
908+
index:
909+
number_of_shards: 5 # Ensure more shards than docs
910+
911+
- do:
912+
indices.create:
913+
index: test-index-002
914+
body:
915+
settings:
916+
index:
917+
number_of_shards: 5 # Ensure more shards than docs
918+
919+
- do:
920+
bulk:
921+
refresh: true
922+
index: test-index-001
923+
body:
924+
- index:
925+
_id: 1
926+
- { "text": "patio" }
927+
- index:
928+
_id: 2
929+
- { "text": "catio" }
930+
931+
- do:
932+
bulk:
933+
refresh: true
934+
index: test-index-002
935+
body:
936+
- index:
937+
_id: 3
938+
- { "text": "balcony" }
939+
- index:
940+
_id: 4
941+
- { "text": "overhang" }
942+
943+
- do:
944+
query_rules.put_ruleset:
945+
ruleset_id: catio-ruleset
946+
body:
947+
rules:
948+
- rule_id: rule1
949+
type: pinned
950+
criteria:
951+
- type: exact
952+
metadata: foo
953+
values: [ bar ]
954+
actions:
955+
ids:
956+
- '2'
957+
958+
- do:
959+
search:
960+
index: test-index-001,test-index-002
961+
body:
962+
retriever:
963+
rule:
964+
retriever:
965+
standard:
966+
query:
967+
query_string:
968+
query: "patio or balcony"
969+
match_criteria:
970+
foo: bar
971+
ruleset_ids: catio-ruleset
972+
973+
- match: { hits.total.value: 3 }
974+
- match: { hits.hits.0._id: '2' }

0 commit comments

Comments
 (0)