From db2adb6795a41a9a34ec33b6174cd2eee75abc1d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 25 Oct 2024 01:31:25 +0000 Subject: [PATCH] set the refresh policy to IMMEDIATE when updating correlation alerts (#1382) Signed-off-by: Riya Saxena (cherry picked from commit 4166c796966ad878953f2fd59fe3dd1353939632) Signed-off-by: github-actions[bot] --- .../correlation/alert/CorrelationAlertService.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/opensearch/securityanalytics/correlation/alert/CorrelationAlertService.java b/src/main/java/org/opensearch/securityanalytics/correlation/alert/CorrelationAlertService.java index e5c43698b..56f446cd4 100644 --- a/src/main/java/org/opensearch/securityanalytics/correlation/alert/CorrelationAlertService.java +++ b/src/main/java/org/opensearch/securityanalytics/correlation/alert/CorrelationAlertService.java @@ -13,6 +13,7 @@ import org.opensearch.action.index.IndexResponse; import org.opensearch.action.search.SearchRequest; import org.opensearch.action.search.SearchResponse; +import org.opensearch.action.support.WriteRequest; import org.opensearch.action.update.UpdateRequest; import org.opensearch.client.Client; import org.opensearch.common.lucene.uid.Versions; @@ -212,9 +213,10 @@ public void acknowledgeAlerts(List alertIds, ActionListener() { @Override public void onResponse(SearchResponse searchResponse) { + // Set the refresh policy on the BulkRequest + bulkRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); // Iterate through the search hits for (SearchHit hit : searchResponse.getHits().getHits()) { - // Construct a script to update the document with the new state and acknowledgedTime // Construct a script to update the document with the new state and acknowledgedTime Script script = new Script(ScriptType.INLINE, "painless", "ctx._source.state = params.state; ctx._source.acknowledged_time = params.time",