簡體   English   中英

如何使用Postman將JSON數組添加到elasticsearch

[英]How to add JSON array to elasticsearch using Postman

我嘗試使用郵遞員通過以下方式添加示例數據集,

POST URL:  http://localhost:9200/allData

以json的形式添加到郵遞員的正文中

{
    "index": "allData",
    "type": "all",
    "id": 1006,
    "body":  {

                    "id": 1006,
                    "url": "https://en.wikiversity.org/wiki/Principles_of_Management",
                    "title": "Principles of Management",
                    "author": "",
                    "rate": 0,
                    "ratedBy": 0,
                    "datePublished": "2018-01-01T00:00:00",
                    "publishedDate": "2018-01-01"   
    }
}

但是它給出以下錯誤。

找不到uri [/]和方法[POST]的處理程序

有人請幫我解決這個問題。 謝謝

您的請求存在某些問題:

  • Elasticsearch指數名稱不能有大寫所以你的情況應該是不ALLDATA ALLDATA。
  • URL格式錯誤。

您的網址應采用以下格式:

http://localhost:9200/{indexname}/{type}/{id}

您的情況必須是:

http://localhost:9200/alldata/all/1006

因此,您應該使用以下內容對上述網址執行POST請求:

{
   "id": 1006,
   "url": "https://en.wikiversity.org/wiki/Principles_of_Management",
   "title": "Principles of Management",
   "author": "",
   "rate": 0,
   "ratedBy": 0,
   "datePublished": "2018-01-01T00:00:00",
   "publishedDate": "2018-01-01"   
}

看一下《 Elasticsearch參考指南》

希望能幫助到你 !

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM