美文网首页
Elasticsearch 添加数据

Elasticsearch 添加数据

作者: 盘木 | 来源:发表于2021-12-13 10:50 被阅读0次

Elasticsearch 添加数据

添加ES 数据

curl -X POST 127.0.0.1:9200/index_001 -d {}

Elasticsearch 批量添加数据
首先我们先构造一个 json文件,内容参考如下(批量请求必须通过换行符[\n]终止):

{"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 "127.0.0.1:9200/_bulk?pretty" -H "Content-Type: application/json;charset=UTF-8" --data-binary @test.json

插入数据的时候他会有一段时间去执行,你需要立即让他去执行添加

立即添加

curl -X GET 127.0.0.1:9200/index_001/_refresh

相关文章

网友评论

      本文标题:Elasticsearch 添加数据

      本文链接:https://www.haomeiwen.com/subject/ntjjfrtx.html