你可以的,加油

elasticsearch批量导入数据注意事项

wj86611199 发表了文章 • 0 个评论 • 11623 次浏览 • 2017-12-16 23:55 • 来自相关话题


刚刚初始化启动kiabna后是没有索引的,当然,如果elasticsearch中导入过数据那么kibana会自动匹配索引
现在按照官方例子开始批量给elasticsearch导入数据
链接如下https://www.elastic.co/guide/e ... .html
我们会依次导入如下 三块数据 
1.The Shakespeare data 莎士比亚文集的数据结构


{
    "line_id": INT,
    "play_name": "String",
    "speech_number": INT,
    "line_number": "String",
    "speaker": "String",
    "text_entry": "String",
}
2.The accounts data  账户数据结构


{
    "account_number": INT,
    "balance": INT,
    "firstname": "String",
    "lastname": "String",
    "age": INT,
    "gender": "M or F",
    "address": "String",
    "employer": "String",
    "email": "String",
    "city": "String",
    "state": "String"
}
3.The schema for the logs data 日志数据


{
    "memory": INT,
    "geo.coordinates": "geo_point"
    "@timestamp": "date"
}
然后向elasticsearch设置字段映射
Use the following command in a terminal (eg bash) to set up a mapping for the Shakespeare data set:
以下是莎士比亚的字段映射 可以用postman或者curl等发出请求~完整的url应该是localhost:9200/shakespear
PUT /shakespeare
{
 "mappings": {
  "doc": {
   "properties": {
    "speaker": {"type": "keyword"},
    "play_name": {"type": "keyword"},
    "line_id": {"type": "integer"},
    "speech_number": {"type": "integer"}
   }
  }
 }
}
Use the following commands to establish geo_point mapping for the logs:
这是 logs的字段映射
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"
            }
          }
        }
      }
    }
  }
}
COPY AS CURLVIEW IN CONSOLE 
PUT /logstash-2015.05.20
{
  "mappings": {
    "log": {
      "properties": {
        "geo": {
          "properties": {
            "coordinates": {
              "type": "geo_point"
            }
          }
        }
      }
    }
  }
}
账户信息没有字段映射。。。
现在批量导入
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
windows下的curl命令可以到https://curl.haxx.se/download.html#Win64下载,解压后设置环境变量即可
这里要注意的是 @accounts.json,@shakespeare_6.0.json,@logs.json这些文件的位置应该是你所在的当前目录,
如果你当前位置是D盘~那么这些文件位置就要放在D盘下,否则读不到
还有一点~~~windows下要把命令行中的单引号换成双引号,,。。。否则会报
curl: (6) Could not resolve host: application这样的错误


 

使用JavaAPI插入1000w数据,控制台报了OOM异常

回复

shabusi 发起了问题 • 1 人关注 • 0 个回复 • 2671 次浏览 • 2017-12-15 18:07 • 来自相关话题

elasticsearch geo point的精度问题

回复

匿名用户 发起了问题 • 1 人关注 • 0 个回复 • 2553 次浏览 • 2017-12-15 17:50 • 来自相关话题

elasticsearch 内存高问题

xufenxu 回复了问题 • 7 人关注 • 3 个回复 • 4413 次浏览 • 2018-03-30 09:40 • 来自相关话题

Caused by: java.lang.ClassNotFoundException: org.elasticsearch.action.main.MainRequest

fskle 回复了问题 • 2 人关注 • 1 个回复 • 9380 次浏览 • 2018-01-27 20:58 • 来自相关话题

ES日期存储

liucp 回复了问题 • 6 人关注 • 4 个回复 • 6818 次浏览 • 2019-03-26 16:33 • 来自相关话题

增加es节点数是否可有效提升索引性能?

ELKer 回复了问题 • 2 人关注 • 1 个回复 • 3492 次浏览 • 2017-12-15 11:32 • 来自相关话题

elasticsearch的monitor监控中机器的CPU Utilization (%)项中的Cgroup CPU Utilization (%)是什么含义呢?

回复

candownyang 发起了问题 • 2 人关注 • 0 个回复 • 3197 次浏览 • 2017-12-15 00:33 • 来自相关话题

elasticsearch 增删改查耗时过多

laoyang360 回复了问题 • 3 人关注 • 1 个回复 • 2672 次浏览 • 2017-12-15 07:23 • 来自相关话题

我是ES初学者,哪位大神能知道安装head插件中需要安装grunt怎么安装,公司需求没有外网,离线安装,求指点,非常感谢

shitangjiejie 回复了问题 • 6 人关注 • 7 个回复 • 9826 次浏览 • 2017-12-20 13:22 • 来自相关话题

搜索时指定分词器,IK粗粒度无效

ELKer 回复了问题 • 3 人关注 • 2 个回复 • 4254 次浏览 • 2017-12-14 20:25 • 来自相关话题

分布式搜索elasticsearch 搜索结果排序不一致性问题

回复

hellowWorld 发起了问题 • 1 人关注 • 0 个回复 • 1862 次浏览 • 2017-12-14 19:04 • 来自相关话题

elasticsearch 排序插件问题

private_void 回复了问题 • 4 人关注 • 1 个回复 • 2085 次浏览 • 2017-12-14 17:36 • 来自相关话题

有谁用过ElasticsearchTemplate做多索引查询的么

回复

hhh 发起了问题 • 1 人关注 • 0 个回复 • 4590 次浏览 • 2017-12-14 16:40 • 来自相关话题

es可以查询id最大的一个么?就是最新一条数据

a2dou 回复了问题 • 4 人关注 • 3 个回复 • 10393 次浏览 • 2020-12-16 13:57 • 来自相关话题