简体   繁体   English

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

[英]How to send elasticsearch multi search request in Postman?

I'm trying to send elasticserach multi search request via postman as below:我正在尝试通过邮递员发送 elasticserach 多搜索请求,如下所示:

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)

Three things are important here:这里有三件事很重要:

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

Body:身体: 在此处输入图片说明

Header:标题:

在此处输入图片说明

Curl version:卷曲版本:

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":{}}}
'

You can also make your request body be json format and change your Content-Type be application/json, please take a look as below您也可以将您的请求正文设置为 json 格式并将您的 Content-Type 更改为 application/json,请查看以下内容

带有内容类型的标题

您的 json 类型搜索请求

响应数据

I have found error for "Expected [START_OBJECT] but found [null]" when I use _msearch API in elasticsearch.当我在 elasticsearch 中使用 _msearch API 时,我发现“预期 [START_OBJECT] 但发现 [null]”错误。

Response of this api这个api的响应

Request parameters and url请求参数和url

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM