From d6572517e1c5f9628d5f428aa89e7c83b0d1f18e Mon Sep 17 00:00:00 2001 From: Shenoy Pratik Date: Wed, 23 Aug 2023 14:34:14 -0700 Subject: [PATCH] update index search preference Signed-off-by: Shenoy Pratik --- .../org/opensearch/observability/index/ObservabilityIndex.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/kotlin/org/opensearch/observability/index/ObservabilityIndex.kt b/src/main/kotlin/org/opensearch/observability/index/ObservabilityIndex.kt index b0c45997c..5b295b236 100644 --- a/src/main/kotlin/org/opensearch/observability/index/ObservabilityIndex.kt +++ b/src/main/kotlin/org/opensearch/observability/index/ObservabilityIndex.kt @@ -54,6 +54,7 @@ internal object ObservabilityIndex { private const val NOTEBOOKS_INDEX_NAME = ".opensearch-notebooks" private const val OBSERVABILITY_MAPPING_FILE_NAME = "observability-mapping.yml" private const val OBSERVABILITY_SETTINGS_FILE_NAME = "observability-settings.yml" + private const val SEARCH_ACTION_PREFERENCE = "_primary" private var mappingsUpdated: Boolean = false private lateinit var client: Client @@ -298,6 +299,7 @@ internal object ObservabilityIndex { val searchRequest = SearchRequest() .indices(INDEX_NAME) .source(sourceBuilder) + .preference(SEARCH_ACTION_PREFERENCE) val actionFuture = client.search(searchRequest) val response = actionFuture.actionGet(PluginSettings.operationTimeoutMs) val result = ObservabilityObjectSearchResult(request.fromIndex.toLong(), response, searchHitParser)