(八)ElasticSearch常用查询语法

简单查询、条件查询、聚合查询
(1)创建book索引

代码:
{
	"settings":{
		"number_of_shards":3,
		"number_of_replicas":1
	},
	"mappings":{
		"novel":{
			"properties":{
				"word_count":{
					"type":"integer"
				},
				"author":{
					"type":"keyword"
				},
				"title":{
					"type":"text"
				},
				"publish_date":{
					"type":"date",
					"format":"yyyy-MM-dd HH:mm:ss || yyyy-MM-dd || epoch_millis"
				}
			}
			
		}
	}
}
(2)插入数据

(3)GET请求,查询id为1数据

(4)条件查询

结果:

(5)指定返回数据大小,以及从哪里返回

结果:

(6)按关键词查询以及排序

结果:

(7)聚合查询

结果:


7-1)聚合中的计算:

结果:

7-2)直接指定最小值

结果:

只有把命运掌握在自己手中,从今天起开始努力,即使暂时看不到希望,也要相信自己。因为比你牛几倍的人,依然在努力。
原文地址:https://www.cnblogs.com/freesky168/p/14358265.html