# 创建 Elasticsearch 客户端连接
client = Elasticsearch(hosts=['localhost']) # 根据实际情况修改主机地址
# 定义查询请求体
query_body = {
"query": {
"bool": {
"must": [
{"match": {"field1": "value1"}},
{"match": {"field2": "value2"}},
{"match": {"field3": "value3"}}
]
}
}
}
# 发送查询请求
response = client.search(index='your_index_name', body=query_body) # 根据实际情况修改索引名称
# 处理查询结果
for hit in response['hits']['hits']:
print(hit['_source'])
es查询时同时指定多个字段
最新推荐文章于 2024-07-19 16:36:18 发布