天天看点

ElasticSearch的Sample Data,即测试数据

ElasticSearch的sample data:

1 account.zip

https://github.com/bly2k/files/blob/master/accounts.zip?raw=true

2 shakespeare.json

https://www.elastic.co/guide/en/kibana/3.0/snippets/shakespeare.json

3 logs.json1.gz

https://download.elastic.co/demos/kibana/gettingstarted/logs.jsonl.gz

将他们加载入ES。

先解压缩,然后使用命令批量加载。

curl -XPOST 'localhost:9200/bank/account/_bulk?pretty' --data-binary "@accounts.json"
省略了很多数据
  }, {
    "index" : {
      "_index" : "bank",
      "_type" : "account",
      "_id" : "990",
      "_version" : 1,
      "_shards" : {
        "total" : 2,
        "successful" : 1,
        "failed" : 0
      },
      "status" : 201
    }
  }, {
    "index" : {
      "_index" : "bank",
      "_type" : "account",
      "_id" : "995",
      "_version" : 1,
      "_shards" : {
        "total" : 2,
        "successful" : 1,
        "failed" : 0
      },
      "status" : 201
    }
  } ]
}
[[email protected] ~]$ curl 'localhost:9200/_cat/indices?v'
health status index    pri rep docs.count docs.deleted store.size pri.store.size 
yellow open   bank       5   1       1000            0      447kb          447kb 
[[email protected] ~]$
           

shaekspeare和logs,先做mapping。

[[email protected] es]$ curl -XPUT http://localhost:9200/shakespeare -d '
 {
  "mappings" : {
   "_default_" : {
    "properties" : {
     "speaker" : {"type": "string", "index" : "not_analyzed" },
     "play_name" : {"type": "string", "index" : "not_analyzed" },
     "line_id" : { "type" : "integer" },
     "speech_number" : { "type" : "integer" }
    }
   }
  }
 }
 ';
{"acknowledged":true} 
[[email protected] es]$
           

logs

[[email protected] es]$ curl -XPUT http://localhost:9200/logstash-2015.05.18 -d '
 {
   "mappings": {
     "log": {
       "properties": {
         "geo": {
           "properties": {
             "coordinates": {
               "type": "geo_point"
             }
           }
         }
       }
     }
   }
 }
 ';
{"acknowledged":true}[[email protected] es]$
           

同样的方法:

[[email protected] es]$ curl -XPUT http://localhost:9200/logstash-2015.05.19 -d '
 {
   "mappings": {
     "log": {
       "properties": {
         "geo": {
           "properties": {
             "coordinates": {
               "type": "geo_point"
             }
           }
         }
       }
     }
   }
 }
 ';
{"acknowledged":true}[[email protected] es]$ 
[[email protected] es]$ curl -XPUT http://localhost:9200/logstash-2015.05.20 -d '
 {
   "mappings": {
     "log": {
       "properties": {
         "geo": {
           "properties": {
             "coordinates": {
               "type": "geo_point"
             }
           }
         }
       }
     }
   }
 }
 ';
{"acknowledged":true}[[email protected] es]$
           

同样的数据加载命令:

curl -XPOST 'localhost:9200/bank/account/_bulk?pretty' --data-binary @accounts.json
curl -XPOST 'localhost:9200/shakespeare/_bulk?pretty' --data-binary @shakespeare.json
curl -XPOST 'localhost:9200/_bulk?pretty' --data-binary @logs.jsonl
           

版权声明:本文为CSDN博主「weixin_34237596」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。

原文链接:https://blog.csdn.net/weixin_34237596/article/details/92637542

下一篇: json格式数据