错误消息:'[bool]格式错误的查询,应为[END_OBJECT],但找到[FIELD_NAME]'(
查询:
{'query':{
'bool': {
'must': {
'bool': {
'should': [
{'match': {'title' : a[0]}},
{'match': {'title' : a[1]}}
],
'minimum_should_match': 1
}
}
}
},
}
我已经搜索了几个问题,但仍然无法找出查询中的错误位置。
更新:这完全是我的问题。我认为错误是在布尔查询上,所以我删除了一些我认为与原始问题无关的代码。实际查询如下:
search_body_try1 = {'query':{
'bool': {
'must': {
'bool': {
'should': [
{'match': {'title' : a[0]}},
{'match': {'title' : a[1]}}
],
'minimum_should_match': 1
}
}
},
'sort':[{'_score': {'order':'desc'}},
{'_id': {'order':'desc'}}]
},
'size':200
}
现在在我看来,问题是'sort'
应该放在query
之外?
查询的格式确实不正确。sort
需要与size
和query
处于相同的级别,即:
{
"query": {
"bool": {
"must": [
{
"bool": {
"should": [
{
"match": {
"title": a[0]
}
},
{
"match": {
"title": a[1]
}
}
],
"minimum_should_match": 1
}
}
]
}
},
"sort": [
{
"_score": {
"order": "desc"
}
},
{
"_id": {
"order": "desc"
}
}
],
"size": 200
}
如果有score
字段,请将_score
替换为score
。与CCD_ 9类似。