Skip to content

Commit

Permalink
[Backport 2.11] Backport #1427 and #1464 to 2.11 (#1479)
Browse files Browse the repository at this point in the history
* Feature findings enhancemnt (#1427) (#1457)

* added support for  param in Finding API



* added detectionType as param for Findings API enhancements



* added searchString param in FIndingsAPI



* adding addiional params findingIds, startTime and endTime



---------


(cherry picked from commit 2420c2c)

Signed-off-by: Riya Saxena <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* Findings API Enhancements changes and integ tests fix (#1464) (#1474)

* solution to fix integ tests

Signed-off-by: Riya Saxena <[email protected]>

* fix flaky DocumentMonitor Runner tests

Signed-off-by: Riya Saxena <[email protected]>

* fix findings API enhancemnts

Signed-off-by: Riya Saxena <[email protected]>

---------

Signed-off-by: Riya Saxena <[email protected]>
(cherry picked from commit ba84d04)

* fix integ tests

Signed-off-by: Joanne Wang <[email protected]>

---------

Signed-off-by: Riya Saxena <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Signed-off-by: Joanne Wang <[email protected]>
Co-authored-by: opensearch-trigger-bot[bot] <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Riya <[email protected]>
  • Loading branch information
4 people authored Mar 15, 2024
1 parent dde6aab commit ce74c3e
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import org.opensearch.commons.alerting.model.FindingWithDocs
import org.opensearch.commons.utils.recreateObject
import org.opensearch.core.action.ActionListener
import org.opensearch.core.common.Strings
import org.opensearch.core.common.io.stream.NamedWriteableRegistry
import org.opensearch.core.xcontent.NamedXContentRegistry
import org.opensearch.core.xcontent.XContentParser
import org.opensearch.core.xcontent.XContentParserUtils
Expand All @@ -62,7 +63,8 @@ class TransportGetFindingsSearchAction @Inject constructor(
clusterService: ClusterService,
actionFilters: ActionFilters,
val settings: Settings,
val xContentRegistry: NamedXContentRegistry
val xContentRegistry: NamedXContentRegistry,
val namedWriteableRegistry: NamedWriteableRegistry
) : HandledTransportAction<ActionRequest, GetFindingsResponse> (
AlertingActions.GET_FINDINGS_ACTION_NAME,
transportService,
Expand All @@ -83,7 +85,7 @@ class TransportGetFindingsSearchAction @Inject constructor(
actionListener: ActionListener<GetFindingsResponse>
) {
val getFindingsRequest = request as? GetFindingsRequest
?: recreateObject(request) { GetFindingsRequest(it) }
?: recreateObject(request, namedWriteableRegistry) { GetFindingsRequest(it) }
val tableProp = getFindingsRequest.table

val sortBuilder = SortBuilders
Expand All @@ -101,12 +103,11 @@ class TransportGetFindingsSearchAction @Inject constructor(
.seqNoAndPrimaryTerm(true)
.version(true)

val queryBuilder = QueryBuilders.boolQuery()
val queryBuilder = getFindingsRequest.boolQueryBuilder ?: QueryBuilders.boolQuery()

if (!getFindingsRequest.findingId.isNullOrBlank()) {
queryBuilder.filter(QueryBuilders.termQuery("_id", getFindingsRequest.findingId))
}

if (getFindingsRequest.monitorId != null) {
queryBuilder.filter(QueryBuilders.termQuery("monitor_id", getFindingsRequest.monitorId))
} else if (getFindingsRequest.monitorIds.isNullOrEmpty() == false) {
Expand Down Expand Up @@ -134,7 +135,6 @@ class TransportGetFindingsSearchAction @Inject constructor(
)
)
}

searchSourceBuilder.query(queryBuilder)

client.threadPool().threadContext.stashContext().use {
Expand Down

0 comments on commit ce74c3e

Please sign in to comment.