Properly handle matched and meta fields, always return sentiment aggregations
This commit is contained in:
@@ -358,12 +358,12 @@ class ElasticsearchBackend(StorageBackend):
|
||||
add_top.append(range_query)
|
||||
self.add_bool(search_query, add_bool)
|
||||
self.add_top(search_query, add_top)
|
||||
if "sentiment" in data:
|
||||
search_query["aggs"] = {
|
||||
"avg_sentiment": {
|
||||
"avg": {"field": "sentiment"},
|
||||
}
|
||||
# if "sentiment" in data:
|
||||
search_query["aggs"] = {
|
||||
"avg_sentiment": {
|
||||
"avg": {"field": "sentiment"},
|
||||
}
|
||||
}
|
||||
|
||||
return search_query
|
||||
|
||||
@@ -374,8 +374,12 @@ class ElasticsearchBackend(StorageBackend):
|
||||
for index, (meta, result) in result_map.items():
|
||||
# Default to true, if no aggs are found, we still want to match
|
||||
match = True
|
||||
print("RULE OBJECT", rule_object.aggs)
|
||||
print("META", meta)
|
||||
for agg_name, (operator, number) in rule_object.aggs.items():
|
||||
if agg_name in meta:
|
||||
print("AGG NAME", agg_name, "OPERATOR", operator, "NUMBER", number)
|
||||
|
||||
if agg_name in meta["aggs"]:
|
||||
agg_value = meta["aggs"][agg_name]["value"]
|
||||
|
||||
# TODO: simplify this, match is default to True
|
||||
|
||||
Reference in New Issue
Block a user