Elasticsearch 模板不读取参数
Elasticsearch template not reading params
我一直在关注此站点 Parameterizing Queries in Solr and Elasticsearch ES 部分中的示例。请注意,作者使用的是较旧的 ES 版本,但我认为这不会影响这种情况。我正在使用 ES 的 1.6 版。
我有一个模板 {{ES_HOME}}/config/scripts/test.mustache
,类似于以下代码段。注意 "query".
中的 {{q}}
参数
{
"query": {
"multi_match": {
"query": "{{q}}",
"analyzer": "keyword",
"fields": [
"description^10",
"name^50",
]
}
},
"aggregations": {
"doctype" : {
"terms" : {
"field" : "doctype.untouched"
}
}
}
}
我POST到http://localhost:9200/forward/_search/template
邮件正文如下
{
"template": {
"file": "test",
"params": {
"q": "a"
}
}
}
它运行模板,但获得 0 次点击,并且 returns 以下内容:
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
},
"aggregations": {
"doctype": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": []
},
}
}
或者,如果我将 "a" 硬编码到 {{q}} 所在的位置,并将 post 硬编码到模板,它会正确 returns 查询结果 "a".我在我的设计中做错了什么吗?
根据 docs,params
对象应该在 template
对象之外
{
"template": {
"file": "test"
},
"params": {
"q": "a"
}
}
我一直在关注此站点 Parameterizing Queries in Solr and Elasticsearch ES 部分中的示例。请注意,作者使用的是较旧的 ES 版本,但我认为这不会影响这种情况。我正在使用 ES 的 1.6 版。
我有一个模板 {{ES_HOME}}/config/scripts/test.mustache
,类似于以下代码段。注意 "query".
{{q}}
参数
{
"query": {
"multi_match": {
"query": "{{q}}",
"analyzer": "keyword",
"fields": [
"description^10",
"name^50",
]
}
},
"aggregations": {
"doctype" : {
"terms" : {
"field" : "doctype.untouched"
}
}
}
}
我POST到http://localhost:9200/forward/_search/template
邮件正文如下
{
"template": {
"file": "test",
"params": {
"q": "a"
}
}
}
它运行模板,但获得 0 次点击,并且 returns 以下内容:
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
},
"aggregations": {
"doctype": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": []
},
}
}
或者,如果我将 "a" 硬编码到 {{q}} 所在的位置,并将 post 硬编码到模板,它会正确 returns 查询结果 "a".我在我的设计中做错了什么吗?
根据 docs,params
对象应该在 template
对象之外
{
"template": {
"file": "test"
},
"params": {
"q": "a"
}
}