elastic 6.x 利用restApi 与集群进行交互 .3.4

导入数据到es

如下json格式数据

{
    "account_number": 0,
    "balance": 16623,
    "firstname": "Bradshaw",
    "lastname": "Mckenzie",
    "age": 29,
    "gender": "F",
    "address": "244 Columbus Place",
    "employer": "Euron",
    "email": "[email protected]",
    "city": "Hobucken",
    "state": "CO"

}

通过命令

curl -H "Content-Type: application/json" -XPOST "localhost:9200/bank/_doc/_bulk?pretty&refresh" --data-binary "@files.json"
curl "localhost:9200/_cat/indices?v"


导入数据.

数据查询;

 
 

GET /bank/_search?q=*&sort=account_number:asc&pretty

扫描二维码关注公众号,回复: 62862 查看本文章

GET /bank/_search
{
  "query": { "match_all": {} }
}

match_all 搜索所有

GET /bank/_search
{
  "query": { "match_all": {} },
  "size": 1

}

size:为显示一个文档

GET /bank/_search

{
  "query": { "match_all": {} },
  "from": 10,
  "size": 10
}

from-size:显示10-19个文档.

GET /bank/_search
{
  "query": { "match_all": {} },
  "sort": { "balance": { "order": "desc" } }
}

order:倒叙排序.


猜你喜欢

转载自blog.csdn.net/weixin_38098312/article/details/80076164
3.4