Answer the question
In order to leave comments, you need to log in
Why doesn't elasticsearch filter by range?
Good afternoon
, elastic search works very strangely, it does not filter or filters crookedly by range I
filter by the price field, integer type
This query returns 1 record
{
"query": {
"bool": {
"filter": [
{
"range": {
"price": {
"gte": 100,
"lte" : 10000000
}
}
}
]
}
}
}
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 1,
"relation": "eq"
},
"max_score": 0.0,
"hits": [
{
"_index": "indexsearchj",
"_type": "_doc",
"_id": "4064",
"_score": 0.0,
"_source": {
"name": "Раз два три",
"id": 4064,
"id_category": 1,
"price": 100000,
"is_my": 1,
"business_type": "3",
"area": "1123",
"property-type": "1",
"itemType": "2",
"metro": "18",
"metro-closest": "7"
}
}
]
}
}
{
"query": {
"bool": {
"filter": [
{
"range": {
"price": {
"gte": 100,
"lte" : 6000000
}
}
}
]
}
}
}
{
"took": 5,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 12,
"relation": "eq"
},
"max_score": 0.0,
"hits": [
{
"_index": "indexsearch",
"_type": "_doc",
"_id": "1311",
"_score": 0.0,
"_source": {
"name": "",
"id": 1311,
"id_category": 1,
"price": 60000,
"is_my": 0,
"area": "40",
"property-type": "1",
"itemType": "2",
"business_type": "3",
"metro": "4",
"metro-closest": "8"
}
},
Answer the question
In order to leave comments, you need to log in
Either filter or range (and, or), and you have filter { range }. I think the problem is this.
It should probably be like:
"query": {
"range": {
"price": {
"gte": 100,
"lte": 10000000
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question