gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 02:43:50 24 4
gpt4 key购买 nike

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

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

但是,我收到以下错误:

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

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

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

最佳答案

这里有三件事很重要:

  1. 插入正文时,从下拉列表中选择原始单选按钮和文本(或 JSON)。
  2. 添加 header :Content-type:application/x-ndjson
  3. 最重要的是:在查询的最后一行之后放置新行

正文: enter image description here

标题:

enter image description here

curl 版本:

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

关于elasticsearch - 如何在 Postman 中发送 elasticsearch 多搜索请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45437217/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com