2017-08-01 113 views
3

我試圖通過郵遞員送elasticserach多搜索請求如下:如何在Postman中發送elasticsearch多重搜索請求?

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) 
+0

不知道這是否是問題,但msearch是GET和POST不 – Amityo

回答

3

三樣東西是很重要的位置:

  1. 當插入體,選擇單選按鈕,並從下拉菜單文本(或JSON)。
  2. 添加標題:內容類型:應用程序/ x-ndjson
  3. 最重要的是:把新行查詢的最後一行

體內後: enter image description here

頭部:

enter image description here

捲曲版本:

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

謝謝喬安娜。我錯過了將'content-type'設置爲'application/x-ndjson'的部分。 –