Skip to content

Commit

Permalink
Make the query more specific
Browse files Browse the repository at this point in the history
  • Loading branch information
petya-vasileva committed Apr 16, 2024
1 parent 1c208c7 commit 9fd7d39
Showing 1 changed file with 47 additions and 23 deletions.
70 changes: 47 additions & 23 deletions src/model/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,31 +373,55 @@ def queryTraceChanges(dateFrom, dateTo, asn=None):
dateFrom = hp.convertDate(dateFrom)
dateTo = hp.convertDate(dateTo)

q = {
if asn:
q = {
"query": {
"bool": {
"must": [
{
"range": {
"from_date": {
"gte": dateFrom,
"format": "strict_date_optional_time"
}
}
},
{
"range": {
"to_date": {
"lte": dateTo,
"format": "strict_date_optional_time"
}
}
},
{
"terms": {
"diff": [asn]
}
}
]
}
}
}

else:
q = {
"query": {
"bool": {
"must": [
{
"range": {
"from_date": {
"gte": dateFrom,
"format": "strict_date_optional_time"
}
}
},
{
"range": {
"to_date": {
"lte": dateTo,
"format": "strict_date_optional_time"
}
}
},
asn_filter
]
}
"bool": {
"must": [
{
"range": {
"to_date": {
"from": dateFrom,
"to": dateTo,
"format": "strict_date_optional_time"
}
}
}
]
}
}
}
}

# print(str(q).replace("\'", "\""))
result = scan(client=hp.es,index='ps_traces_changes',query=q)
Expand Down

0 comments on commit 9fd7d39

Please sign in to comment.