1.查看es下所有的东西 http://localhost:9200/_cat
2.查看es下所有的索引 http://localhost:9200/_cat/indices
3.查看索引bank的索引结构 http://localhost:9200/bank/
4.卸载x-package bin/elasticsearch-plugin remove x-pack
5.终端命令行查看索引情况 curl localhost:9200/_cat/indices?v'
7.put 有指定id post自动生成id
8.更新用post 支持脚本方式
9.排序 http://localhost:9200/bank/_search?q=*&sort=account_number:desc&pretty 字段account_number 按倒序排列。倒序desc 正序 asc
等同于:
GET http://localhost:9200/bank/_search
{
"query": { "match_all": {} },
"sort": [
{ "account_number": "desc" }
]
}
10.过滤加排序 http://localhost:9200/bank/_search?q=firstname:Bradshaw&sort=account_number:asc&pretty firstname是Bradshaw并且字段account_number 按倒序排列
11.结果集解释:
took – es执行搜索花费的时间(毫秒)
timed_out – 搜索是否超时
_shards – 告诉我们,多少分片被搜索,搜索时成功/失败的分片各多少。
hits – 搜索结果
hits.total – 匹配我们搜索条件的文档数量。
hits.hits – 实际搜索出的结果数组。(默认显示前10条)
hits.sort - 搜索出的排序
hits._score and max_score - 搜索匹配分数
12.我们可以在命令中端执行通过DSL方式去查询,可以通过 curl 'http://localhost:9200/bank/_search?pretty' --data-binary "@b.json",其中,--data-binary 参数可以执行本地DSL,注意执行该语句时,DSL文件(b.json)一定要在当前目录(bin目录下)
也可以通过以下方式:
curl -XGET 'localhost:9200/bank/_search?pretty' -H 'Content-Type: application/json' -d'
{
"query": { "match_all": {} }
}
'