使用Python进行ElasticSearch查询

1mrurvl1  于 2023-08-03  发布在  ElasticSearch
关注(0)|答案(1)|浏览(73)

我遇到了一个用python进行es查询的问题。我使用的查询是:

response = es_host.search(index=f"<index>,
                                   query={
                                       "aggs": {"0": {"terms": {"field": "parsed_log.requestPath.keyword",
                                                                         "order": {"_count": "desc"},
                                                                         "size": 10000}}}, "size": 0,
                                                "script_fields": {},
                                                "stored_fields": ["*"], "runtime_mappings": {},
                                                "query": {"bool": {"must": [],
                                                                   "filter": [{"match_phrase": {
                                                                       "parsed_log.responseStatusCode": 200}},
                                                                              {"range": {"log-time": {
                                                                                  "format": "strict_date_optional_time",
                                                                                  "gte": "2023-07-20T03:30:00.000Z",
                                                                                  "lte": "2023-07-21T03:30:00.000Z"}}}],
                                                                   "should": [], "must_not": []}}})

字符串
给出以下错误:elasticsearch.BadRequestError:400,'parsing_exception','unknown query [aggs]'错误
有人能让我知道这里发生了什么,也有解决办法吗?

o2rvlv0m

o2rvlv0m1#

尝试将查询替换为正文。示例如下:

es_host.search(index="index_name", body={ ... })

字符串

相关问题