Elasticsearch初探

Posted 快鸟

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Elasticsearch初探相关的知识,希望对你有一定的参考价值。

  •  elasticsearch中的概念同传统数据库的类比如下:

Relational DB -> Databases -> Tables -> Rows -> Columns
Elasticsearch -> Indices -> Types -> Documents -> Fields

关系数据库     ⇒ 数据库 ⇒ 表    ⇒ 行    ⇒ 列(Columns)
Elasticsearch  ⇒ 索引   ⇒ 类型  ⇒ 文档  ⇒ 字段(Fields)

 

  • 导入数据API:
curl -XPOST \'http://localhost:9200/prd/xjb3/_bulk\' --data-binary @last.json

 

  • last.json文件里面的数据格式形如:<数据地址:http://files.cnblogs.com/files/kevin-yuan/elasticsearchJsonData.zip>
{"index":{"_id":"1"}}
{"account_number":1,"balance":39225,"firstname":"Amber","lastname":"Duke","age":32,"gender":"M","address":"880 Holmes Lane","employer":"Pyrami","email":"amberduke@pyrami.com","city":"Brogan","state":"IL"}
{"index":{"_id":"6"}}
{"account_number":6,"balance":5686,"firstname":"Hattie","lastname":"Bond","age":36,"gender":"M","address":"671 Bristol Street","employer":"Netagy","email":"hattiebond@netagy.com","city":"Dante","state":"TN"}
{"index":{"_id":"13"}}
{"account_number":13,"balance":32838,"firstname":"Nanette","lastname":"Bates","age":28,"gender":"F","address":"789 Madison Street","employer":"Quility","email":"nanettebates@quility.com","city":"Nogal","state":"VA"}

 

  • 排序查询API:
http://localhost:9200/prd/xjb3/_search?sort=balance:desc

 

  • 指定返回条数:加上size=N即可
http://localhost:9200/prd/xjb3/_search?sort=amount:desc&size=100

 

资料:

[1] http://learnes.net/index.html  文档github地址:https://github.com/GavinFoo/elasticsearch-definitive-guide

以上是关于Elasticsearch初探的主要内容,如果未能解决你的问题,请参考以下文章

Elasticsearch聚合--Metrics初探

Elasticsearch初探

elasticsearch terms aggs初探

初探ELK-elasticsearch使用小结

ES — — elasticsearch初探

Elasticsearch6.x使用初探