Elasticsearch 基础查询
1. term 查询
id查询
{
"query": {
"term": {
"_id": "1574082604628477954"
}
}
}
查询某个字段
{
"query": {
"term": {
"orderId": 9876543216
}
}
}
2. 分页查询
{
"from": 0,
"size": 20,
"query": {}
}
3. bool 查询
{
"from": 0,
"size": 20,
"query": {
"bool": {
"must": [
{
"term": { "userPin": { "value": "e9eca00" } }
}
]
}
}
}
4. 集群健康
curl -X GET "localhost:9200/_cluster/health?pretty"
返回值
{
"cluster_name" : "my-application",
"status" : "yellow",
"timed_out" : false,
"number_of_nodes" : 1,
"number_of_data_nodes" : 1,
"active_primary_shards" : 8,
"active_shards" : 8,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 5,
"delayed_unassigned_shards" : 0,
"number_of_pending_tasks" : 0,
"number_of_in_flight_fetch" : 0,
"task_max_waiting_in_queue_millis" : 0,
"active_shards_percent_as_number" : 61.53846153846154
}
status 字段指示着当前集群在总体上是否工作正常。它的三种颜色含义如下:
green
所有的主分片和副本分片都正常运行。yellow
所有的主分片都正常运行,但不是所有的副本分片都正常运行。red
有主分片没能正常运行。
unassigned_shards
没有被分配到任何节点的副本数。