【问题标题】:How to use Elasticsearch search templates in multi search (_msearch) API?如何在多搜索 (_msearch) API 中使用 Elasticsearch 搜索模板?
【发布时间】:2015-03-20 03:54:32
【问题描述】:

是否可以在多搜索 api (_msearch) 请求中使用已注册的搜索模板? 如果有,怎么做?

我尝试在正文中给出以下查询。

POST /_msearch
{"index":"index1","type":"type1"}
{"template":{"id":"template_1"},"params":{"a":1, "b":2}}

但这会导致错误:

Parse Failure [No parser for element [template]]

我尝试将所有内容包装在查询中:

POST /_msearch
{"index":"index1","type":"type1"}
{"query":{"template":{"id":"template_1"},"params":{"a":1, "b":2}}}

和 POST 到 _msearch/template,但这些也不起作用。

提前致谢

【问题讨论】:

    标签: templates search elasticsearch


    【解决方案1】:

    目前不支持,但他们有一个开放的增强请求。 Add template support to _msearch #10885

    【讨论】:

      【解决方案2】:

      此功能于 2016 年添加,这里是使用 6.8 模板进行多搜索的文档(目前支持的最旧的 ES 版本):

      https://www.elastic.co/guide/en/elasticsearch/reference/6.8/multi-search-template.html

      【讨论】:

        猜你喜欢
        • 2018-10-05
        • 1970-01-01
        • 1970-01-01
        • 2021-08-12
        • 2018-05-29
        • 2022-06-18
        • 2019-02-09
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多