样本数据集
既然我们已经对基础有了一定了解,就让我们在更真实的数据集上做一些练习吧。我准备了一些客户银行账户信息的JSON格式的假数据。每个文档都有如下所示的结构:
{ "account_number": 0, "balance": 16623, "firstname": "Bradshaw", "lastname": "Mckenzie", "age": 29, "gender": "F", "address": "244 Columbus Place", "employer": "Euron", "email": "bradshawmckenzie@euron.com", "city": "Hobucken", "state": "CO" }
这些数据是我在网站 http://www.json-generator.com/ 上生成的,所以不必太在意这些数据在语义上的不真实,因为全都是随机生成的。
加载样本数据集
你可以在这里下载这个样本数据集(accounts.json)。 解压到当前目录,然后使用下面的命令把这些数据载入咱们的集群中:
curl -H "Content-Type: application/json" -XPOST 'localhost:9200/bank/account/_bulk?pretty&refresh' --data-binary "@accounts.json" curl 'localhost:9200/_cat/indices?v'
返回:
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size yellow open bank -_IHCJWAQ06D7E-wPpL19A 5 1 1000 0 640.1kb 640.1kb yellow open customer V0DAWcw3TGSeaefMqvGOIg 5 1 3 0 10.4kb 10.4kb
上面的结果意味着我们刚刚成功批量为1000个文档在bank索引下建立了account类型的索引。
本文系本人根据官方文档的翻译,能力有限、水平一般,如果对想学习Elasticsearch的朋友有帮助,将是本人的莫大荣幸。
原文出处:https://www.elastic.co/guide/en/elasticsearch/reference/current/_exploring_your_data.html