fix:修复es6.8查询不到数据问题 (#12069)

Co-authored-by: feng <1304903146@qq.com>
pull/12076/head
fit2bot 2023-11-09 14:18:49 +08:00 committed by GitHub
parent f47895b8a8
commit d60fe464ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 13 deletions

View File

@ -177,9 +177,10 @@ class ES(object):
body = self.get_query_body(**query) body = self.get_query_body(**query)
data = self.es.search( data = self.es.search(
index=self.query_index, doc_type=self.doc_type, body=body, index=self.query_index, body=body,
from_=from_, size=size, sort=sort from_=from_, size=size, sort=sort
) )
source_data = [] source_data = []
for item in data['hits']['hits']: for item in data['hits']['hits']:
if item: if item:
@ -191,7 +192,7 @@ class ES(object):
def count(self, **query): def count(self, **query):
try: try:
body = self.get_query_body(**query) body = self.get_query_body(**query)
data = self.es.count(index=self.query_index, doc_type=self.doc_type, body=body) data = self.es.count(index=self.query_index, body=body)
count = data["count"] count = data["count"]
except Exception as e: except Exception as e:
logger.error('ES count error: {}'.format(e)) logger.error('ES count error: {}'.format(e))

View File

@ -1,26 +1,25 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
from django.utils import translation
from django.utils import timezone from django.utils import timezone
from rest_framework import generics from rest_framework import generics
from rest_framework.fields import DateTimeField from rest_framework.fields import DateTimeField
from rest_framework.response import Response from rest_framework.response import Response
from acls.models import CommandFilterACL, CommandGroup from acls.models import CommandFilterACL, CommandGroup
from terminal.models import CommandStorage, Session, Command
from terminal.filters import CommandFilter
from orgs.utils import current_org
from common.api import JMSBulkModelViewSet from common.api import JMSBulkModelViewSet
from common.utils import get_logger from common.utils import get_logger
from terminal.serializers import ( from orgs.utils import current_org
SessionCommandSerializer, InsecureCommandAlertSerializer
)
from terminal.exceptions import StorageInvalid
from terminal.backends import ( from terminal.backends import (
get_command_storage, get_multi_command_storage get_command_storage, get_multi_command_storage
) )
from terminal.notifications import CommandAlertMessage, CommandWarningMessage
from terminal.const import RiskLevelChoices from terminal.const import RiskLevelChoices
from terminal.exceptions import StorageInvalid
from terminal.filters import CommandFilter
from terminal.models import CommandStorage, Session, Command
from terminal.notifications import CommandAlertMessage, CommandWarningMessage
from terminal.serializers import (
SessionCommandSerializer, InsecureCommandAlertSerializer
)
logger = get_logger(__name__) logger = get_logger(__name__)
__all__ = ['CommandViewSet', 'InsecureCommandAlertAPI'] __all__ = ['CommandViewSet', 'InsecureCommandAlertAPI']
@ -140,8 +139,8 @@ class CommandViewSet(JMSBulkModelViewSet):
if session_id and not command_storage_id: if session_id and not command_storage_id:
# 会话里的命令列表肯定会提供 session_id这里防止 merge 的时候取全量的数据 # 会话里的命令列表肯定会提供 session_id这里防止 merge 的时候取全量的数据
return self.merge_all_storage_list(request, *args, **kwargs) return self.merge_all_storage_list(request, *args, **kwargs)
queryset = self.get_queryset()
queryset = self.filter_queryset(self.get_queryset()) queryset = self.filter_queryset(queryset)
page = self.paginate_queryset(queryset) page = self.paginate_queryset(queryset)
if page is not None: if page is not None: