Skip to content

Commit

Permalink
set the refresh policy to IMMEDIATE when updating correlation alerts (#…
Browse files Browse the repository at this point in the history
…1382)

Signed-off-by: Riya Saxena <[email protected]>
(cherry picked from commit 4166c79)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] committed Oct 25, 2024
1 parent f09ff2b commit db2adb6
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -212,9 +213,10 @@ public void acknowledgeAlerts(List<String> alertIds, ActionListener<AckCorrelati
client.search(searchRequest, new ActionListener<SearchResponse>() {
@Override
public void onResponse(SearchResponse searchResponse) {
// Set the refresh policy on the BulkRequest
bulkRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);

Check warning on line 217 in src/main/java/org/opensearch/securityanalytics/correlation/alert/CorrelationAlertService.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/securityanalytics/correlation/alert/CorrelationAlertService.java#L217

Added line #L217 was not covered by tests
// 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",
Expand Down

0 comments on commit db2adb6

Please sign in to comment.