Windows下使用curl命令向elasticsearch导入示例数据出错问题
2018-04-09 15:45
1246 查看
准备工作
假设你已经安装好了kibana和elasticsearch,使用kibana,在加载数据之前,我们需要建立一个映射的字段。
首先创建一个名为shakespeare的索引可以在kibana控制台运行:
PUT /shakespeare { "mappings": { "doc": { "properties": { "speaker": {"type": "keyword"}, "play_name": {"type": "keyword"}, "line_id": {"type": "integer"}, "speech_number": {"type": "integer"} } } } }
也可以在终端运行下面的命令:
(注:windows中使用curl命令需要下载curl工具,官网下载解压后将.exe文件拷贝到C:\Windows\System32,这样就可以在DOS窗口任意位置使用curl命令
)
curl -XPUT 'localhost:9200/shakespeare?pretty' -H 'Content-Type: application/json' -d' { "mappings": { "doc": { "properties": { "speaker": {"type": "keyword"}, "play_name": {"type": "keyword"}, "line_id": {"type": "integer"}, "speech_number": {"type": "integer"} } } } } '
为日志文件创建索引
PUT /logstash-2015.05.18 { "mappings": { "log": { "properties": { "geo": { "properties": { "coordinates": { "type": "geo_point" } } } } } } }
PUT /logstash-2015.05.19 { "mappings": { "log": { "properties": { "geo": { "properties": { "coordinates": { "type": "geo_point" } } } } } } }
PUT /logstash-2015.05.20 { "mappings": { "log": { "properties": { "geo": { "properties": { "coordinates": { "type": "geo_point" } } } } } } }
也可以使用终端命令:
curl -XPUT 'localhost:9200/logstash-2015.05.18?pretty' -H 'Content-Type: application/json' -d' { "mappings": { "log": { "properties": { "geo": { "properties": { "coordinates": { "type": "geo_point" } } } } } } } '
curl -XPUT 'localhost:9200/logstash-2015.05.19?pretty' -H 'Content-Type: application/json' -d' { "mappings": { "log": { "properties": { "geo": { "properties": { "coordinates": { "type": "geo_point" } } } } } } } '
curl -XPUT 'localhost:9200/logstash-2015.05.20?pretty' -H 'Content-Type: application/json' -d' { "mappings": { "log": { "properties": { "geo": { "properties": { "coordinates": { "type": "geo_point" } } } } } } } '
accounts(账目)数据集不需要任何 mapping(映射)
下面开始导入数据,使用下面的命令:
curl -H 'Content-Type: application/x-ndjson' -XPOST 'localhost:9200/bank/account/_bulk?pretty' --data-binary @accounts.json curl -H 'Content-Type: application/x-ndjson' -XPOST 'localhost:9200/shakespeare/doc/_bulk?pretty' --data-binary @shakespeare_6.0.json curl -H 'Content-Type: application/x-ndjson' -XPOST 'localhost:9200/_bulk?pretty' --data-binary @logs.jsonl
这些数据的加载需要一定的时间,请耐心等待!
使用下面命令查看数据加载情况:
GET 9638 /_cat/indices?v
或者使用curl命令:
curl -XGET 'localhost:9200/_cat/indices?v&pretty'
OK! ! !
相关文章推荐
- MongoDB数据使用-如何在Windows环境下使用mongorestore命令导入bson文件
- MySql使用全记录5 -----解决Windows下用命令导入sql文件时"Failed to open file"的问题
- Windows中Oracle使用Doc命令完成数据的导出(EXP)/导入(IMP)
- 使用Oracle 的 imp ,exp 命令实现数据的导入导出
- 关于程序调用Sqlldr不出错但数据导入不成功的问题
- 在Windows下使用curl命令
- 数据库操作_连接SQL Server数据库示例;连接ACCESS数据库;连接到 Oracle 数据库示例;SqlCommand 执行SQL命令示例;SqlDataReader 读取数据示例;使用DataAdapter填充数据到DataSet;使用DataTable存储数据库表;将数据库数据填充到 XML 文件;10 使用带输入参数的存储过程;11 使用带输入、输出参数的存储过程示;12 获得数据库中表的数目和名称;13 保存图片到SQL Server数据库示例;14 获得插入记录标识号;Exce
- 使用Oracle 的 imp ,exp 命令实现数据的导入导出
- 使用Oracle 的 imp ,exp 命令实现数据的导入导出
- 使用命令导入导出mysql数据表的记录
- 在oracle中 生成大规模数据 500万条 (使用导入数据方式 sqlldr 导入命令 *.ctl文件)
- SQL2008如何使用空间工具(Spatial Tools)导入ESRI格式地图数据的示例
- SqlServer 数据的导入导出,使用bcp命令
- 使用 SQOOP 导入 SQL SERVER 2008 R2 数据出错
- 使用Oracle 的 imp ,exp 命令实现数据的导入导出
- 使用Oracle 的 imp ,exp 命令实现数据的导入导出(转)
- 使用Oracle 的 imp ,exp 命令实现数据的导入导出
- 在SQL Server的查询分析器中使用命令导入Excel表格中的数据
- 问题集锦07:使用T-SQL导入数据时报错“将截断字符串或二进制数据”
- MSSQL中使用命令行BCP命令导入导出数据