我正在使用elasticsearch 2.3.3
。我正在尝试使用以下mustache script
设置模板查询:
{
"from":"{{from}}",
"size":"{{size}}",
"query": {
"multi_match": {
"query": "{{query}}",
"type": "most_fields",
"fields": [ "meta.court^1.5",
"meta.judge^1.5",
"meta.suit_no^4",
"meta.party1^1.5",
"meta.party2^1.5",
"meta.subject^3",
"content"]
}
}
}
我已成功将此脚本编入索引,如下所示:
POST /_search/template/myscript
{
"script":{
"from":"{{from}}"
,"size":"{{size}}"
,"query": {
"multi_match": {
"query": "{{query}}",
"type": "most_fields",
"fields": [ "meta.court^1.5", "meta.judge^1.5", "meta.suit_no^4", "meta.party1^1.5", "meta.party2^1.5", "meta.subject^3", "content"]
}
}
}
}
然而,当我尝试使用以下代码渲染模板时:
GET _render/template
{
"id": "myscript",
"params":{
"from":"0"
,"size":"10"
,"query":"walter"
}
}
我收到以下错误:
{
"error": {
"root_cause": [
{
"type": "json_parse_exception",
"reason": "Unexpected character ('=' (code 61)): was expecting a colon to separate field name and value\n at [Source: [B@39f8927e; line: 1, column: 8]"
}
],
"type": "json_parse_exception",
"reason": "Unexpected character ('=' (code 61)): was expecting a colon to separate field name and value\n at [Source: [B@39f8927e; line: 1, column: 8]"
},
"status": 500
}
有趣的是,如果脚本作为文件存储在es节点的config / scripts目录中,我可以成功执行该脚本。
我在这里缺少什么?任何帮助将不胜感激。
非常感谢