如何在 Postman 中发送 elasticsearch 多搜索请求? [英] How to send elasticsearch multi search request in Postman?

查看:15
本文介绍了如何在 Postman 中发送 elasticsearch 多搜索请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过邮递员发送 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)

推荐答案

这里有三件事很重要:

  1. 插入正文时,从下拉列表中选择 raw 单选按钮和 Text(或 JSON).
  2. 添加标题:内容类型:application/x-ndjson
  3. 最重要的是:将换行放在查询的最后一行之后
  1. When inserting body, select raw radiobutton and Text (or JSON) from dropdown.
  2. Add header: Content-type: application/x-ndjson
  3. 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":{}}}
'

这篇关于如何在 Postman 中发送 elasticsearch 多搜索请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆