Loading

导入ElasticSearch官方测试数据

学习ES的过程中,苦于测试数据不全,手动插入数据速度太慢,后来发现ES官方提供了一些测试数据可以直接导入到自建的ES,但是由于官方文档的没有更新,导入过程中会报错,具体原因是ES废弃的index中的type概念。官方文档

  1. 莎士比亚索引库
PUT /shakespeare
{
"mappings": {
  "properties": {
   "speaker": {"type": "keyword"},
   "play_name": {"type": "keyword"},
   "line_id": {"type": "integer"},
   "speech_number": {"type": "integer"}
  }
}
}

2.日志索引库

PUT /logstash-2015.05.18
{
  "mappings": {
      "properties": {
        "geo": {
          "properties": {
            "coordinates": {
              "type": "geo_point"
            }
          }
        }
      }
  }
}

PUT /logstash-2015.05.19
{
  "mappings": {
      "properties": {
        "geo": {
          "properties": {
            "coordinates": {
              "type": "geo_point"
            }
          }
        }
      }
  }
}

PUT /logstash-2015.05.20
{
  "mappings": {
      "properties": {
        "geo": {
          "properties": {
            "coordinates": {
              "type": "geo_point"
            }
          }
        }
      }
  }
}
  • 账户数据集不需要任何映射,基于这一点我们准备用 Elasticsearch bulk API 来加载数据集,命令如下:
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
posted @ 2023-01-31 14:48  _fun_ny  阅读(906)  评论(0)    收藏  举报