如何在elasticsearch中插入数据 [英] How to insert data into elasticsearch
问题描述
我是 Elasticsearch 的新手,我已经尝试了 2 天向 Elasticsearch 插入一些数据.我在谷歌上发现有很多页面可以帮助创建索引(我不清楚索引",是不是其他术语中的插入"?)然后很多地方给出了一些curl命令,我真的不知道在哪里执行这些代码行插入数据.示例:
I am new to Elasticearch, and I have been trying for 2 days to insert some data into Elasticearch. I found on Google that there are many pages to help to create an index (I am not clear about "index", does it mean "insert" in other terms?) Then many places give some curl command, and I really don't know where to execute these code lines to insert data. Example:
curl -XPOST "http://[localhost]:9200/indexname/typename/optionalUniqueId" -d '{ "field" : "value" }'
我正在使用 Window 7,并且我已经安装了 Java 并成功运行了 elasticsearch.谁能告诉我有关如何将数据插入 Elasticsearch 的更多详细信息
I am using Window 7 and I have installed Java and run elasticsearch successfully. Could anybody show me more details about how to insert data into Elasticearch
非常感谢
推荐答案
您必须先在 PC 中安装 curl
二进制文件.你可以下载它 从这里.
You have to install the curl
binary in your PC first. You can download it from here.
然后将其解压缩到一个文件夹中.让我们说 C:curl
.在该文件夹中,您将找到带有多个 .dll
文件的 curl.exe
文件.
After that unzip it into a folder. Lets say C:curl
. In that folder you'll find curl.exe
file with several .dll
files.
现在通过从开始菜单
中键入cmd
来打开命令提示符.然后在那里输入 cd c:curl
,它会带你到 curl 文件夹.现在执行您拥有的 curl
命令.
Now open a command prompt by typing cmd
from the start menu
. And type cd c:curl
on there and it will take you to the curl folder. Now execute the curl
command that you have.
有一件事,windows 不支持围绕字段的单引号.所以你必须使用双引号.例如,我已将您的 curl 命令转换为适当的命令.
One thing, windows doesn't support single quote around around the fields. So you have to use double quotes. For example I have converted your curl command like appropriate one.
curl -H "Content-Type: application/json" -XPOST "http://localhost:9200/indexname/typename/optionalUniqueId" -d "{ "field" : "value"}"
这篇关于如何在elasticsearch中插入数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!