具有术语和范围的 elasticsearch-dsl-py 查询过滤器

elasticsearch-dsl-py query filter with term and range

我正在尝试使用术语和范围以及查询字符串来过滤查询。 filter(range) 和查询字符串有效,但 filter(term) 无效。我做错了什么吗?

es = Elasticsearch([{'host': '192.168.121.121', 'port': 9200}])

index = Index("filebeat-*",using=es)
search = index.search()
searchStr = "OutOfMemoryError"

search = search.query("query_string", query=searchStr)
search = search.filter('range' ,  **{'@timestamp': {'gte': 1589399137000 , 'lt': 1589399377000, 'format' : 'epoch_millis'}})
search = search.filter('term'  , **{'can.deployment': 'can-*' })
response = search.execute(ignore_cache=True)
print(response.hits.total)
print(response.hits.hits._source.can.deployment)

json:

filter-term - ['hits']['hits']['_source']['can']['deployment']
filter-range- ['hits']['hits']['_source']['@timestamp']
{
  "hits" : {
    "total" : 138351328,
    "max_score" : 6.5700893,
    "hits" : [
      {
        "_index" : "filebeat-6.1.2-2020.05.13",
        "_type" : "doc",
        "_score" : 2.0166037,
        "_source" : {
          "@timestamp" : "2020-05-13T01:14:03.354Z",
          "source" : "/var/log/gw_rest/gw_rest.log",
          "message" : "[2020-05-13 01:14:03.354] WARN can_gw_rest [EventLoopGroup-3-2]: An exceptionCaught() event was fired.OutOfMemoryError,
          "fileset" : {...},
          "can" : {
            "level" : "WARN",
>>>>>>>>    "message" : "An exceptionCaught() event was fired- OutOfMemoryError,
            "timestamp" : "2020-05-13 01:14:03.354",
>>>>>>>>    "deployment" : "can-6b721b93965b-w3we4-4074-9903"
          }
        }
      }
    ]
  }
}

我其实不需要过滤器(term)。这有效:

dIds=response['hits']['hits'][1]['_source']['can']['deployment']
print(dIds)
#loop through the response
for i in response['hits']['hits']:
          id = i['_source']['can']['deployment']
          print(id)