【发布时间】:2022-01-14 07:19:04
【问题描述】:
我在 elasticsearch 查询中使用嵌套以及排序。当我在没有排序查询的情况下执行时,但是当我包含排序时,它会给出消息 [bool] 格式错误的查询,预期 [END_OBJECT] 但找到 [FIELD_NAME]。我正在用 python 构建这个查询。提前致谢。
query = {
'bool': {
'should': [
{'nested': {
'path': 'profile.summay',
'query': {
'query_string': {
'query': 'machine learning',
'fields': ['profile.summay.desc'],
'default_operator': "AND"
}
}
}},
{'nested': {
'path': 'internal.summary',
'query': {
'query_string': {
'query': 'machine learning',
'fields': ['internal.summary.desc'],
'default_operator': "AND"
}
}
}}
]
},
"sort": [
{
'profile.summary.date':{
'order' : 'asc',
"nested": { "path": "profile.summary" }
}
}
]
}
from elasticsearch import Elasticsearch
es_client = Elasticsearch(['some aws url'])
response = es_client.search(index=index_name, query=query)
【问题讨论】:
标签: python elasticsearch