您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
elasticSearch范围查询
发布时间:2021-09-06 22:46:23编辑:雪饮阅读()
- gte − 大于和等于
- gt − 大于
- lte − 小于和等于
- lt − 小于
ElasticSearch范围查询用于查找值的范围之间的值的对象。 为此,需要使用类似 -
例如:
请求体:
{
"query":{
"range":{
"rating":{
"gte":3.5
}
}
}
}
响应体:
{
"took": 508,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 4,
"relation": "eq"
},
"max_score": 1.0,
"hits": [
{
"_index": "schools",
"_type": "school",
"_id": "1",
"_score": 1.0,
"_source": {
"name": "Central School",
"description": "CBSE Affiliation",
"street": "Nagan",
"city": "paprola",
"state": "HP",
"zip": "176115",
"location": [
31.8955385,
76.8380405
],
"fees": 2000,
"tags": [
"Senior Secondary",
"beautiful campus"
],
"rating": "3.5"
}
},
{
"_index": "schools",
"_type": "school",
"_id": "2",
"_score": 1.0,
"_source": {
"name": "Saint Paul School",
"description": "ICSE Afiliation",
"street": "Dawarka",
"city": "Delhi",
"state": "Delhi",
"zip": "110075",
"location": [
28.5733056,
77.0122136
],
"fees": 5000,
"tags": [
"Good Faculty",
"Great Sports"
],
"rating": "4.5"
}
},
{
"_index": "schools",
"_type": "school",
"_id": "3",
"_score": 1.0,
"_source": {
"name": "Central School",
"description": "ICSE",
"street": "West End",
"city": "pune",
"state": "UP",
"zip": "250002",
"location": [
28.9926174,
77.692485
],
"fees": 3500,
"tags": [
"fully computerized"
],
"rating": "4.5"
}
},
{
"_index": "schools",
"_type": "school",
"_id": "4",
"_score": 1.0,
"_source": {
"name": "pune",
"description": "ICSE",
"street": "West End",
"state": "UP",
"zip": "250002",
"location": [
28.9926174,
77.692485
],
"fees": 3500,
"tags": [
"fully computerized"
],
"rating": "4.5"
}
}
]
}
}
关键字词:elasticSearch,范围,查询