文章40 | 阅读 24282 | 点赞0
#根据日期范围查询
#范围查询
GET /lib3/user/_search
{
"query": {
"range": {
"birthday": {
"from": "1990-10-10",
"to": "2020-03-15"
}
}
}
}
{
"took" : 24,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 3,
"max_score" : 1.0,
"hits" : [
{
"_index" : "lib3",
"_type" : "user",
"_id" : "2",
"_score" : 1.0,
"_source" : {
"name" : "zhaoming",
"address" : "bei jing hai dian qu qing he zhen",
"age" : 20,
"birthday" : "1998-10-12",
"interests" : "xi huan hejiu, duanlian, changge"
}
},
{
"_index" : "lib3",
"_type" : "user",
"_id" : "4",
"_score" : 1.0,
"_source" : {
"name" : "wangwu",
"address" : "bei jing hai dian qu qing he zhen",
"age" : 26,
"birthday" : "1995-10-12",
"interests" : "xi huan biancheng, tingyinyue, lvyou"
}
},
{
"_index" : "lib3",
"_type" : "user",
"_id" : "3",
"_score" : 1.0,
"_source" : {
"name" : "lisi",
"address" : "bei jing hai dian qu qing he zhen",
"age" : 23,
"birthday" : "1998-10-12",
"interests" : "xi huan hejiu,duanlian, changge"
}
}
]
}
}
**#include_lower 设置为true 包含最小值 #include_upper 设置为false 不包含最大值 **
#include_lower 设置为true 包含最小值
#include_upper 设置为false 不包含最大值
GET /lib3/user/_search
{
"query": {
"range": {
"age": {
"from": 20,
"to": 25,
"include_lower": true,
"include_upper": false
}
}
}
}
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 1.0,
"hits" : [
{
"_index" : "lib3",
"_type" : "user",
"_id" : "2",
"_score" : 1.0,
"_source" : {
"name" : "zhaoming",
"address" : "bei jing hai dian qu qing he zhen",
"age" : 20,
"birthday" : "1998-10-12",
"interests" : "xi huan hejiu, duanlian, changge"
}
},
{
"_index" : "lib3",
"_type" : "user",
"_id" : "3",
"_score" : 1.0,
"_source" : {
"name" : "lisi",
"address" : "bei jing hai dian qu qing he zhen",
"age" : 23,
"birthday" : "1998-10-12",
"interests" : "xi huan hejiu,duanlian, changge"
}
}
]
}
}
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://blog.csdn.net/ywl470812087/article/details/104876943
内容来源于网络,如有侵权,请联系作者删除!