【问题标题】:Elasticsearch multi search APIElasticsearch 多搜索 API
【发布时间】:2018-10-05 22:48:29
【问题描述】:

我正在尝试使用 Elasticsearch(版本 6)执行多个并发搜索请求。这是我的查询文件:

{"index" : "web"}
{"max_concurrent_searches": 64, "query": {"match": {"content": "school"}}}
{"index" : "web"}
{"max_concurrent_searches": 64, "query": {"match": {"content": "car"}}}
{"index" : "web"}
{"max_concurrent_searches": 64, "query": {"match": {"content": "cat"}}}

这是我用来发出批量请求的命令:

curl -H "Content-Type: application/x-ndjson" -XGET ''$url'/_msearch'
--data-binary "@$file"; echo

但是,我收到以下错误,表明我错误地使用了 max_concurrent_searches 参数。

{"error":{"root_cause":[{"type":"parsing_exception","reason":"Unknown key for a VALUE_NUMBER in [max_concurrent_searches].","line":1,"col":29}],"type":"parsing_exception","reason":"Unknown key for a VALUE_NUMBER in [max_concurrent_searches].","line":1,"col":29},"status":400}

如果我从上面的查询文件中删除"max_concurrent_searches": 64,,一切都会完美。

我想知道如何使用/设置max_concurrent_searches 参数,除了以下内容,我在Elasticsearch documentation 中找不到有用的信息:

msearch 的 max_concurrent_searches 请求参数可用于 控制多搜索api的最大并发搜索数 将执行。此默认值基于数据节点的数量和 默认搜索线程池大小。

【问题讨论】:

    标签: elasticsearch concurrency


    【解决方案1】:

    您也可以使用 postman 执行上述操作。只需将内容类型更改为application/x-ndjson,并且不要忘记在最后添加一个换行符。这会给你同样的错误,你可以通过不同的组合轻松地纠正它。 MultiSearch 是一项重要功能。

    【讨论】:

      【解决方案2】:

      您应该将它添加到请求本身:

      示例请求:GET indexName/type/_msearch?ma​​x_concurrent_searches=1100 (其中 indexName 和 type 是可选的)

      对你来说应该是这样的:

      curl -H "Content-Type: application/x-ndjson" -XGET ''$url'/_msearch**? 
      max_concurrent_searches=1100**'
      --data-binary "@$file"; echo
      

      【讨论】:

        猜你喜欢
        • 2021-08-12
        • 2014-04-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-12-08
        • 1970-01-01
        • 1970-01-01
        • 2015-03-20
        相关资源
        最近更新 更多