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

上一篇:How to Use Android ADB Command Line Tool


下一篇:jquery如何在异步方式中给全局变量赋值