mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-07-06 11:36:32 +00:00
fix: ES search session count
This commit is contained in:
parent
ede5fd906c
commit
1a78eb8bb7
@ -315,6 +315,10 @@ class ES(object):
|
||||
})
|
||||
return _filter
|
||||
|
||||
@staticmethod
|
||||
def is_keyword(props: dict, field: str) -> bool:
|
||||
return props.get(field, {}).get("type", "keyword") == "keyword"
|
||||
|
||||
def get_query_body(self, **kwargs):
|
||||
new_kwargs = {}
|
||||
for k, v in kwargs.items():
|
||||
@ -347,13 +351,16 @@ class ES(object):
|
||||
.get('mappings', {})
|
||||
.get('properties', {})
|
||||
)
|
||||
org_id_type = props.get('org_id', {}).get('type', 'keyword')
|
||||
|
||||
common_keyword_able = exact_fields | keyword_fields
|
||||
|
||||
for k, v in kwargs.items():
|
||||
if k == 'org_id' and org_id_type == 'keyword':
|
||||
if k in ("org_id", "session") and self.is_keyword(props, k):
|
||||
exact[k] = v
|
||||
elif k in exact_fields.union(keyword_fields):
|
||||
exact['{}.keyword'.format(k)] = v
|
||||
|
||||
elif k in common_keyword_able:
|
||||
exact[f"{k}.keyword"] = v
|
||||
|
||||
elif k in match_fields:
|
||||
match[k] = v
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user