Elasticsearch 添加數據
# 添加ES 數據 curl -X POST 10.44.99.102:9200/situation-event/situation-event -d {}
Elasticsearch 批量添加數據
首先我們先構造一個 json文件,內容參考如下:
{"index": {"_index": "situation-event"} {"question": "通過源碼安裝進行到第四步的時候空白", "anwser":"anwser1"} {"index": {"_index": "situation-event"} {"question": "為什么windows一鍵安裝包apache無法啟動?", "anwser":"anwser2"} {"index": {"_index": "situation-event"} {"question": "windows一鍵安裝包默認的用戶名和密碼是什么?", "anwser":"anwser3"} {"index": {"_index": "situation-event"}} {"question": "windows一鍵安裝包無法開機自動啟動", "anwser":"anwser4"} {"index": {"_index": "situation-event"}} {"qustion": "安裝的時候提示沒有pdo擴展", "anwser":"anwser5"}
在json文件所在文件夾執行以下命令:
curl -X POST "10.44.99.102:9200/_bulk?pretty" -H "Content-Type: application/json;charset=UTF-8" --data-binary @test.json
插入數據的時候他會有一段時間去執行,你需要立即讓他去執行添加
# 立即添加 curl -X GET 10.44.99.102:9200/situation-event/_refresh