虽然这里有很多线程与ElasticSearch的错误有关,但这些错误的开头是“ ...中的START_OBJECT的未知密钥”,但没有一个答案可以帮助我解决我的特定问题。
这是我对现有的ElasticSearch索引的调用:
{
"size": 150,
"query": {
"bool": {
"must": {
"nested": {
"path": "entities",
"query": {
"match": {
"entities.name": "donald trump"
}
}
}
}
}
},
"should":
{
"nested": {
"path": "entities",
"query": {
"match_phrase": {
"entities.name": {
"query": "donald trump",
"slop": 5
}
}
}
}
},
"rescore": {
"window_size": 2000,
"query": {
"score_mode": "max",
"rescore_query": {
"nested": {
"path": "entities",
"score_mode": "max",
"query": {
"function_score": {
"doc_score": {
"field": "entities.name",
"query_value": "donald trump"
}
}
}
}
}
}
},
"query_weight": 0,
"rescore_query_weight": 1
}
这是我得到的错误:
{
"error": {
"root_cause": [
{
"type": "parsing_exception",
"reason": "Unknown key for a START_OBJECT in [should].",
"line": 19,
"col": 4
}
],
"type": "parsing_exception",
"reason": "Unknown key for a START_OBJECT in [should].",
"line": 19,
"col": 4
},
"status": 400
}
如果不太明显,则第19行为:"should":
我已将此查询与我的一位同事的类似查询进行了比较,该查询没有问题,并且尝试使用should
子句无法识别或纠正该问题。一般而言,我还是ElasticSearch和JSON的新手,因此,我很确定这是用户的无知和经验不足。有人可以帮我诊断和纠正此错误吗?