Multiple Range filter query

Hi,

I can create the facet for the ranges. But if I select more than one facet I want to be able to
filter on it with OR filter which doesn't seem to give me correct results.

The count for vehicles between 1995 to 2000 = 661
The count for vehicles between 2000 to 2005 = 837

When I execute below query it returns 1367 results. It should have returned 661+837=1498 results?

{
"query": {
"filtered": {
"query": {
"bool": {
"must": [
{
"term": {
"vehicle.entityType": "vehicle"
}
}
]
}
},
"filter": {
"or": [
{
"range": {
"vehicleYear": {
"from": 1995,
"to": 2000
}
}
},
{
"range": {
"vehicleYear": {
"from": 2000,
"to": 2005
}
}
}
]
}
}
}
}

The from and to values of a range filter are inclusive, so both clauses of
the range filter will match vehicles from the year 2000 and the duplicates
are omitted. Judging by your results, 131 vehicles are from 2000.

For better performance, you can use a match all query and move your term
query into the filter section.

--
Ivan

On Fri, Apr 26, 2013 at 11:22 AM, yree yashashree.lad@gmail.com wrote:

Hi,

I can create the facet for the ranges. But if I select more than one facet
I
want to be able to
filter on it with OR filter which doesn't seem to give me correct results.

The count for vehicles between 1995 to 2000 = 661
The count for vehicles between 2000 to 2005 = 837

When I execute below query it returns 1367 results. It should have returned
661+837=1498 results?

{
"query": {
"filtered": {
"query": {
"bool": {
"must": [
{
"term": {
"vehicle.entityType": "vehicle"
}
}
]
}
},
"filter": {
"or": [
{
"range": {
"vehicleYear": {
"from": 1995,
"to": 2000
}
}
},
{
"range": {
"vehicleYear": {
"from": 2000,
"to": 2005
}
}
}
]
}
}
}
}

--
View this message in context:
http://elasticsearch-users.115913.n3.nabble.com/Multiple-Range-filter-query-tp4033894.html
Sent from the Elasticsearch Users mailing list archive at Nabble.com.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Thanks so much for your response. It worked when I included lower value and
made include upper -false. The counts matched!

On Sat, Apr 27, 2013 at 7:21 PM, Ivan Brusic [via Elasticsearch Users] <
ml-node+s115913n4033921h73@n3.nabble.com> wrote:

The from and to values of a range filter are inclusive, so both clauses of
the range filter will match vehicles from the year 2000 and the duplicates
are omitted. Judging by your results, 131 vehicles are from 2000.

For better performance, you can use a match all query and move your term
query into the filter section.

--
Ivan

On Fri, Apr 26, 2013 at 11:22 AM, yree <[hidden email]http://user/SendEmail.jtp?type=node&node=4033921&i=0

wrote:

Hi,

I can create the facet for the ranges. But if I select more than one
facet I
want to be able to
filter on it with OR filter which doesn't seem to give me correct results.

The count for vehicles between 1995 to 2000 = 661
The count for vehicles between 2000 to 2005 = 837

When I execute below query it returns 1367 results. It should have
returned
661+837=1498 results?

{
"query": {
"filtered": {
"query": {
"bool": {
"must": [
{
"term": {
"vehicle.entityType": "vehicle"
}
}
]
}
},
"filter": {
"or": [
{
"range": {
"vehicleYear": {
"from": 1995,
"to": 2000
}
}
},
{
"range": {
"vehicleYear": {
"from": 2000,
"to": 2005
}
}
}
]
}
}
}
}

--
View this message in context:
http://elasticsearch-users.115913.n3.nabble.com/Multiple-Range-filter-query-tp4033894.html
Sent from the Elasticsearch Users mailing list archive at Nabble.com.

--
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 [hidden email]http://user/SendEmail.jtp?type=node&node=4033921&i=1
.
For more options, visit https://groups.google.com/groups/opt_out.

--
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 [hidden email]http://user/SendEmail.jtp?type=node&node=4033921&i=2
.
For more options, visit https://groups.google.com/groups/opt_out.


If you reply to this email, your message will be added to the discussion
below:

http://elasticsearch-users.115913.n3.nabble.com/Multiple-Range-filter-query-tp4033894p4033921.html
To unsubscribe from Multiple Range filter query, click herehttp://elasticsearch-users.115913.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4033894&code=eWFzaGFzaHJlZS5sYWRAZ21haWwuY29tfDQwMzM4OTR8LTEzMjcwOTk5OQ==
.
NAMLhttp://elasticsearch-users.115913.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html!nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers!nabble%3Aemail.naml-instant_emails!nabble%3Aemail.naml-send_instant_email!nabble%3Aemail.naml