|
|
|
@ -602,24 +602,28 @@ class ElasticsearchBackend(StorageBackend):
|
|
|
|
|
if isinstance(sentiment_r, dict):
|
|
|
|
|
return sentiment_r
|
|
|
|
|
if sentiment_r:
|
|
|
|
|
if rule_object is not None:
|
|
|
|
|
sentiment_index = "meta.aggs.avg_sentiment.value"
|
|
|
|
|
else:
|
|
|
|
|
sentiment_index = "sentiment"
|
|
|
|
|
sentiment_method, sentiment = sentiment_r
|
|
|
|
|
range_query_compare = {"range": {"sentiment": {}}}
|
|
|
|
|
range_query_compare = {"range": {sentiment_index: {}}}
|
|
|
|
|
range_query_precise = {
|
|
|
|
|
"match": {
|
|
|
|
|
"sentiment": None,
|
|
|
|
|
sentiment_index: None,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if sentiment_method == "below":
|
|
|
|
|
range_query_compare["range"]["sentiment"]["lt"] = sentiment
|
|
|
|
|
range_query_compare["range"][sentiment_index]["lt"] = sentiment
|
|
|
|
|
add_top.append(range_query_compare)
|
|
|
|
|
elif sentiment_method == "above":
|
|
|
|
|
range_query_compare["range"]["sentiment"]["gt"] = sentiment
|
|
|
|
|
range_query_compare["range"][sentiment_index]["gt"] = sentiment
|
|
|
|
|
add_top.append(range_query_compare)
|
|
|
|
|
elif sentiment_method == "exact":
|
|
|
|
|
range_query_precise["match"]["sentiment"] = sentiment
|
|
|
|
|
range_query_precise["match"][sentiment_index] = sentiment
|
|
|
|
|
add_top.append(range_query_precise)
|
|
|
|
|
elif sentiment_method == "nonzero":
|
|
|
|
|
range_query_precise["match"]["sentiment"] = 0
|
|
|
|
|
range_query_precise["match"][sentiment_index] = 0
|
|
|
|
|
add_top_negative.append(range_query_precise)
|
|
|
|
|
|
|
|
|
|
# Add in the additional information we already populated
|
|
|
|
|