Elasticsearch初探

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

Relational DB -> Databases -> Tables -> Rows -> Columns
Elasticsearch -> Indices -> Types -> Documents -> 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":"[email protected]","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":"[email protected]","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":"[email protected]","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

 

你可能感兴趣的:(Elasticsearch初探)