1 Star 0 Fork 324

yhaoquan/Spring-elastic_search

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
REST.txt 3.50 KB
一键复制 编辑 原始数据 按行查看 历史
dell 提交于 2019-08-07 17:21 +08:00 . bugfix
# search
GET sougoulog/_search
{
"query": {
"match_all": {}
},
"from": 0,
"size": 10
}
GET sougoulog/_search
{
"query": {
"match": {
"keywords": {
"query": "国无",
"operator": "and"
}
}
},
"from": 0,
"size": 115
}
# analyze
POST sougoulog/_analyze
{"analyzer" : "standard", "text" : "国无"}
POST sougoulog/_analyze
{"analyzer" : "ik_max_word", "text" : "中华人民共和国"}
POST sougoulog/_analyze
{"analyzer" : "ik_smart", "text" : "中华人民共和国治安管理处罚法"}
# 查询一个文档的词条向量
GET sougoulog/docs/35/_termvectors
{
"fields" : ["keywords","userid"],
"offsets" : true,
"payloads" : true,
"positions" : true,
"term_statistics" : true,
"field_statistics" : true
}
# aggregations
# 度量聚集,查看统计数据
GET sougoulog/_search
{
"query": {
"match_all": {}
},
"from": 0,
"size": 0,
"aggs":{
"countnumber":{
"stats": {
"field": "rank"
}
}
}
}
# terms词条聚集,相当于在字段上group by,不能用于有分词字段的统计
GET sougoulog/_search
{
"query": {
"match_all": {}
},
"from": 0,
"size": 0,
"aggs":{
"countnumber":{
"terms": {
"field": "visittime" ,
"size": 100 ,
"order": {
"_term": "asc"
}
},
"aggs": {
"sum_rank": {
"stats": {
"field": "rank"
}
}
}
}
}
}
# 时间范围聚集date_range,区间左闭右开
GET sougoulog/_search
{
"query": {
"match_all": {}
},
"from": 0,
"size": 0,
"aggs":{
"countnumber":{
"date_range": {
"field": "visittime" ,
"ranges": [
{
"to":"00:03:00"
},{
"from": "00:03:00",
"to":"00:06:00"
},{
"from": "00:06:00",
"to":"00:09:00"
},
{
"from": "00:09:00"
}
]
}
}
}
}
# 直方图聚集,直接传步长,不需要传区间段,interval单位是毫秒
GET sougoulog/_search
{
"query": {
"match_all": {}
},
"from": 0,
"size": 0,
"aggs":{
"countnumber":{
"histogram": {
"field": "visittime" ,
"interval": 180000
}
}
}
}
# 日期直方图聚集,直接传步长,不需要传区间段,interval单位是分钟
GET sougoulog/_search
{
"query": {
"match_all": {}
},
"from": 0,
"size": 0,
"aggs":{
"countnumber":{
"date_histogram": {
"field": "visittime" ,
"interval": "3m"
}
}
}
}
# 嵌套聚集,top_hits用于返回父聚集的前N名
GET sougoulog/_search
{
"query": {
"match_all": {}
},
"from": 0,
"size": 0,
"aggs":{
"countnumber":{
"date_histogram": {
"field": "visittime" ,
"interval": "3m"
},
"aggs":{
"details":{
"top_hits": {
"size": 3,
"sort": [{
"visittime": {
"order": "asc"
}
}]
}
}
}
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/yhaoquan/Spring-elastic_search.git
[email protected]:yhaoquan/Spring-elastic_search.git
yhaoquan
Spring-elastic_search
Spring-elastic_search
master

搜索帮助