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