Skip to content

Commit

Permalink
fix for max & min aggregations when no metric property exist
Browse files Browse the repository at this point in the history
Signed-off-by: Subhobrata Dey <sbcd90@gmail.com>
  • Loading branch information
sbcd90 committed Jul 28, 2023
1 parent d4cafd6 commit 4c7642e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
4 changes: 3 additions & 1 deletion detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ complexity:
LongMethod:
excludes: ['**/test/**']
LongParameterList:
excludes: ['**/test/**']
excludes: ['**/test/**']
NestedBlockDepth:
threshold: 5
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@ class RollupIndexer(
it.aggregations.forEach {
when (it) {
is InternalSum -> aggResults[it.name] = it.value
is InternalMax -> aggResults[it.name] = it.value
is InternalMin -> aggResults[it.name] = it.value
// TODO: Need to redo the logic in corresponding doXContentBody of InternalMax and InternalMin
is InternalMax -> if (it.value.isInfinite()) aggResults[it.name] = null else aggResults[it.name] = it.value
is InternalMin -> if (it.value.isInfinite()) aggResults[it.name] = null else aggResults[it.name] = it.value
is InternalValueCount -> aggResults[it.name] = it.value
is InternalAvg -> aggResults[it.name] = it.value
else -> error("Found aggregation in composite result that is not supported [${it.type} - ${it.name}]")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ abstract class IndexManagementRestTestCase : ODFERestTestCase() {
insertSampleBulkData(index, javaClass.classLoader.getResource("data/nyc_5000.ndjson").readText())
}

protected fun generateMessageLogsData(index: String = "message-logs") {
createIndex(index, Settings.EMPTY, """"properties": {"message":{"properties":{"bytes_in":{"type":"long"},"bytes_out":{"type":"long"},"plugin":{"eager_global_ordinals":true,"ignore_above":10000,"type":"keyword"},"timestamp_received":{"type":"date"}}}}""")
insertSampleBulkData(index, javaClass.classLoader.getResource("data/message_logs.ndjson").readText())
}

@Suppress("UNCHECKED_CAST")
protected fun extractFailuresFromSearchResponse(searchResponse: Response): List<Map<String, String>?>? {
val shards = searchResponse.asMap()["_shards"] as Map<String, ArrayList<Map<String, Any>>>
Expand Down
4 changes: 4 additions & 0 deletions src/test/resources/data/message_logs.ndjson
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{"create":{}}
{"message":{"bytes_out":4256,"plugin":"AlienVault NIDS","timestamp_received":1689786716020}}
{"create":{}}
{"message":{"bytes_out":4526,"plugin":"AlienVault NIDS","timestamp_received":1689886716020}}

0 comments on commit 4c7642e

Please sign in to comment.