如何在邮递员中发送elasticsearch多重搜索请求? [英] How to send elasticsearch multi search request in Postman?
本文介绍了如何在邮递员中发送elasticsearch多重搜索请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正尝试通过邮递员发送弹性搜索多搜索请求,如下所示:
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 单选按钮和下拉列表中的文本(或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":{}}}
'
这篇关于如何在邮递员中发送elasticsearch多重搜索请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文