From 5845e2663f0c2fe32ba7bc1ef0dab4689e91a631 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 1 Sep 2023 19:28:41 +0000 Subject: [PATCH] Add _primary preference only for segment replication enabled indices (#2040) * Add _primary preference only for segment replication enabled indices Signed-off-by: Suraj Singh * Add test for segment replication tests Signed-off-by: Suraj Singh * Remove isSegRepEnabled check and use _primary_first preference Signed-off-by: Suraj Singh * Remove unused ClusterState reference Signed-off-by: Suraj Singh * Self review Signed-off-by: Suraj Singh --------- Signed-off-by: Suraj Singh (cherry picked from commit 9c12628a256c959036c4ca297205b56939860674) Signed-off-by: github-actions[bot] --- .../storage/OpenSearchDataSourceMetadataStorage.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/datasources/src/main/java/org/opensearch/sql/datasources/storage/OpenSearchDataSourceMetadataStorage.java b/datasources/src/main/java/org/opensearch/sql/datasources/storage/OpenSearchDataSourceMetadataStorage.java index 3de924dcbb..5f5e087ce0 100644 --- a/datasources/src/main/java/org/opensearch/sql/datasources/storage/OpenSearchDataSourceMetadataStorage.java +++ b/datasources/src/main/java/org/opensearch/sql/datasources/storage/OpenSearchDataSourceMetadataStorage.java @@ -224,6 +224,8 @@ private List searchInDataSourcesIndex(QueryBuilder query) { searchSourceBuilder.query(query); searchSourceBuilder.size(DATASOURCE_QUERY_RESULT_SIZE); searchRequest.source(searchSourceBuilder); + // https://github.com/opensearch-project/sql/issues/1801. + searchRequest.preference("_primary_first"); ActionFuture searchResponseActionFuture; try (ThreadContext.StoredContext ignored = client.threadPool().getThreadContext().stashContext()) {