我有以下映射:
{
"hero_index": {
"mappings": {
"dynamic": "strict",
"properties": {
"name": {
"type": "keyword"
},
"super_power": {
"type": "keyword"
},
"weakness": {
"type": "keyword"
}
}
}
}
}
一切都很好,直到我想要https://localhost:9200/super_heroes/_msearch一個看起來像這樣的身體:
[
{"query": {"term": {"name": {"term": "Hulk"}}}},
{"index": "super_heroes"},
{"query": {"term": {"word": {"term": "Iron Man"}}}}
]
但我收到以下錯誤...
{
"error": {
"root_cause": [
{
"type": "x_content_parse_exception",
"reason": "[1:2] Unexpected close marker ']': expected '}' (for root starting at [Source: (org.elasticsearch.common.io.stream.ByteBufferStreamInput); line: 1, column: 0])\n at [Source: (org.elasticsearch.common.io.stream.ByteBufferStreamInput); line: 1, column: 2]"
}
],
"type": "x_content_parse_exception",
"reason": "[1:2] Unexpected close marker ']': expected '}' (for root starting at [Source: (org.elasticsearch.common.io.stream.ByteBufferStreamInput); line: 1, column: 0])\n at [Source: (org.elasticsearch.common.io.stream.ByteBufferStreamInput); line: 1, column: 2]",
"caused_by": {
"type": "json_parse_exception",
"reason": "Unexpected close marker ']': expected '}' (for root starting at [Source: (org.elasticsearch.common.io.stream.ByteBufferStreamInput); line: 1, column: 0])\n at [Source: (org.elasticsearch.common.io.stream.ByteBufferStreamInput); line: 1, column: 2]"
}
},
"status": 400
}
我不確定為什么會這樣或如何解決它......有什么想法嗎?
uj5u.com熱心網友回復:
_msearch查詢接受以下格式的正文:
{metadata}
{query}
{metadata}
{query}
您正在嘗試發送 JSON 陣列,這就是您收到錯誤的原因。
試試這個(注意,第一個空白物件是必需的,因為你沒有發送任何元資料):
{ }
{"query": {"term": {"name": {"term": "Hulk"}}}},
{"index": "super_heroes"},
{"query": {"term": {"word": {"term": "Iron Man"}}}}
資源
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/496588.html
標籤:弹性搜索
上一篇:RequestError:RequestError(400,search_phase_execution_exception未能為elasticsearch中的輸入字串創建查詢
