Range filter acts strange

Hi People,

I use the following query to filter my data. Everything works great, untill
I want to use a price-range filter.
This range filter does not do exactly what I expect. I have a product in my
collection with the price=10. When I set the filter to gte:1 - lte:11, it
works, but gte:2 - lte:11 does not work. But the value price = 10 should
match both ranges.

10 - 10 does also give no result, but 10 - 11 does..

Can anyone please help me?

{
"query": {
"match_all": []
},
"filter": {
"and": [
{
"term": {
"representative": 1
}
},
{
"term": {
"is_gift": 0
}
},
{
"term": {
"active": 1
}
},
{
"terms": {
"website_ids": [
1
],
"execution": "and"
}
},
{
"terms": {
"spec_value_ids": [
"587",
"584",
"5828"
],
"execution": "or"
}
},
{
"terms": {
"category_ids": [
"518"
],
"execution": "and"
}
},
{

  • "range": { "price": { "gte":
    2, "lte": 11 } }*
    }
    ]
    },
    "sort": {
    "price": {
    "order": "asc"
    }
    }
    }

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/19155520-7683-48bf-82f1-0c31b419841f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hi,

maybe your price field is of type string, then for strings you have "1" <
"11" < "2". Check your mapping.
My experience with range filters is that they work correctly.

Kind regards,
Florentin

Am Dienstag, 27. Mai 2014 21:55:03 UTC+2 schrieb Dan:

Hi People,

I use the following query to filter my data. Everything works great,
untill I want to use a price-range filter.
This range filter does not do exactly what I expect. I have a product in
my collection with the price=10. When I set the filter to gte:1 - lte:11,
it works, but gte:2 - lte:11 does not work. But the value price = 10 should
match both ranges.

10 - 10 does also give no result, but 10 - 11 does..

Can anyone please help me?

{
"query": {
"match_all":
},
"filter": {
"and": [
{
"term": {
"representative": 1
}
},
{
"term": {
"is_gift": 0
}
},
{
"term": {
"active": 1
}
},
{
"terms": {
"website_ids": [
1
],
"execution": "and"
}
},
{
"terms": {
"spec_value_ids": [
"587",
"584",
"5828"
],
"execution": "or"
}
},
{
"terms": {
"category_ids": [
"518"
],
"execution": "and"
}
},
{

  • "range": { "price": { "gte":
    2, "lte": 11 } }*
    }
    ]
    },
    "sort": {
    "price": {
    "order": "asc"
    }
    }
    }

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/92adc14b-1122-4de6-b774-a71a36fff3ef%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Yes, thats was the problem. I've added a mapping, thanks!

Op woensdag 28 mei 2014 09:03:40 UTC+2 schreef Florentin Zorca:

Hi,

maybe your price field is of type string, then for strings you have "1" <
"11" < "2". Check your mapping.
My experience with range filters is that they work correctly.

Kind regards,
Florentin

Am Dienstag, 27. Mai 2014 21:55:03 UTC+2 schrieb Dan:

Hi People,

I use the following query to filter my data. Everything works great,
untill I want to use a price-range filter.
This range filter does not do exactly what I expect. I have a product in
my collection with the price=10. When I set the filter to gte:1 - lte:11,
it works, but gte:2 - lte:11 does not work. But the value price = 10 should
match both ranges.

10 - 10 does also give no result, but 10 - 11 does..

Can anyone please help me?

{
"query": {
"match_all":
},
"filter": {
"and": [
{
"term": {
"representative": 1
}
},
{
"term": {
"is_gift": 0
}
},
{
"term": {
"active": 1
}
},
{
"terms": {
"website_ids": [
1
],
"execution": "and"
}
},
{
"terms": {
"spec_value_ids": [
"587",
"584",
"5828"
],
"execution": "or"
}
},
{
"terms": {
"category_ids": [
"518"
],
"execution": "and"
}
},
{

  • "range": { "price": { "gte":
    2, "lte": 11 } }*
    }
    ]
    },
    "sort": {
    "price": {
    "order": "asc"
    }
    }
    }

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/b3138e46-054a-4e86-880f-bcf3c9c5e3a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.