如何在 Postman 中发送 elasticsearch 多搜索请求?如何在、Postman、elasticsearch

由网友(紅了眼眶﹌湿了瞳)分享简介:我正在尝试通过邮递员发送 elasticserach 多搜索请求,如下所示:I'm trying to send elasticserach multi search request via postman as below:POST - http://localhost:9200/_msearchcontent...

我正在尝试通过邮递员发送 elasticserach 多搜索请求,如下所示:

I'm trying to send elasticserach multi search request via postman as below:

POST - http://localhost:9200/_msearch
content-type : x-www-form-urlencoded
body:
{"index":"accounts"}
{"query":{"bool":{"should":[{"match":{"owner.first_name":"Creeple"}}]}}}

但是,我收到以下错误:

However, I'm getting following error:

{
  "error": {
    "root_cause": [
      {
        "type": "parse_exception",
        "reason": "Failed to derive xcontent"
      }
    ],
    "type": "parse_exception",
    "reason": "Failed to derive xcontent"
  },
  "status": 400
}

请注意,如果我通过播放代码执行相同的请求,则会成功获取结果.

Note that if I perform same request via my play code, results are succesfully fetched.

WS.url("localhost:9200/_msearch").withHeaders("Content-type" -> "application/x-www-form-urlencoded").post(query)

推荐答案

这里有三件事很重要:

插入正文时,从下拉列表中选择 raw 单选按钮和 Text(或 JSON).添加标题:内容类型:application/x-ndjson最重要的是:将换行放在查询的最后一行之后 When inserting body, select raw radiobutton and Text (or JSON) from dropdown. Add header: Content-type: application/x-ndjson Most important: put new line after the last line of your query

正文:

标题:

卷曲版:

curl -X POST 
  http://127.0.0.1:9200/_msearch 
  -H 'cache-control: no-cache' 
  -H 'content-type: application/x-ndjson' 
  -d '{"index":"script","type":"test"}
{"query":{"match_all":{}}}
'
阅读全文

相关推荐

最新文章