1、查詢全部索引
GET /_cat/indices?v
2、要按文檔數對所有索引進行降序排序
GET /_cat/indices?v&h=index,docs.count&s=docs.count:desc`v`:參數用于顯示列標題
`h`:參數用于指定要顯示的列
`s`:參數用于指定按哪一列進行排序
`desc`:表示按降序排序
3、刪除索引
DELETE 索引名
4、查看集群各個節點
GET _cat/nodes?v
5、查看集群健康狀態
GET _cat/health?v`green`:表示集群正常;
`yellow`:部分shards的primary已分配,replica未分配;
`red`:部分shard的primary未分配
6、查詢索引的結構信息
GET 索引名
7、查詢文檔信息
GET 索引名/_doc/_search
或
GET 索引名/_doc/_search
{"query": {"match_all": {}}
}
8、查詢字符串
GET 索引名/_doc/_search?q=屬性:屬性值
或
GET 索引名/_doc/_search
{"query": {"match": {"屬性": "屬性值"}}
}
9、phrase查詢
GET 索引名/_doc/_search
{"query": {"match_phrase": {"屬性": {"query": "屬性值"}}}
}
10、phrase最左前綴查詢
GET 索引名/_doc/_search
{"query": {"match_phrase_prefix": {"屬性": "屬性值前綴"}}
}
11、多字段查詢
GET 索引名/_doc/_search
{"query": {"bool": {"must": [{"match": {"屬性1": "屬性值1"}},{"match": {"屬性2": "屬性值2"}}]}}
}
12、term查詢
GET 索引名/_doc/_search
{"query": {"term": {"屬性": "屬性值"}}
}
13、按某個字段降序查詢
GET 索引名/_doc/_search
{"query": {"match": {"屬性1": "屬性值1"}},"sort": [{"屬性2": {"order": "desc"}}]
}
14、bool查詢must(and),同時滿足多個條件
GET 索引名/_doc/_search
{"query": {"bool": {"must": [{"match": {"屬性1": "屬性值1"}},{"match": {"屬性2": 屬性值2}}]}}
}
15、bool查詢should(or),滿足一個就行
GET 索引名/_doc/_search
{"query": {"bool": {"should": [{"match": {"屬性1": "屬性值1"}},{"match": {"屬性2": 屬性值2}}]}}
}
16、bool查詢must_not(not),既不是也不是
GET 索引名/_doc/_search
{"query": {"bool": {"must_not": [{"match": {"屬性1": "屬性值1"}},{"match": {"屬性2": "屬性值2"}}]}}
}
17、bool查詢filter,某個字段還可以比較大小范圍
GET 索引名/_doc/_search
{"query": {"bool": {"must": [{"match": {"屬性1": "屬性值1"}}],"filter": {"range": {"屬性2": {"gte": 100,"lte": 200}}}}}
}must改成should,滿足下面的filter但不滿足上面的match也會顯示出來