Geo_distance filter

Hi,

I'm using the geo_distance filter to lookup a list of vehicle dealers
within a radius starting from a GeoPoint location.
The problem is that the returned terms facets ignore the filter and return
the whole count.
Is there any way to get the facets aware of the filters the same as with
queries or to achieve the same thing with the geo_shape query ?

The document mapping:
{
"vehicle": {
"properties": {
"id": {
"type": "long"
},
"label": {
"type": "string"
},
"model": {
"type": "string"
},
"dealer": {
"type": "object",
"properties": {
"id": {
"type": "long"
},
"location": {
"type": "geo_point"
}
}
}
}
}
}

The query:
{
"query": {
"match_all": {}
},
"filter": {
"geo_distance": {
"distance": "200km",
"pin.location": {
"lat": 40,
"lon": -70
}
}
},
"facets": {
"models": {
"terms": {
"field": "model"
}
}
}
}

Here the model facet returns the same count as if we remove the filter.

I will really appreciate your help.

Regards,

--
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.

Hey,

if you want the facets to use the filter, use a filtered query inside of
your "query" field which incorporates the "filter" field. A top level
filter is never used for facets. Alternatively you can also add facet
filters to your facet query in order to reduce results.

Hope this helps.

--Alex

On Wed, May 22, 2013 at 10:57 AM, Mehrez Marouani <mehrez.marouani@gmail.com

wrote:

Hi,

I'm using the geo_distance filter to lookup a list of vehicle dealers
within a radius starting from a GeoPoint location.
The problem is that the returned terms facets ignore the filter and return
the whole count.
Is there any way to get the facets aware of the filters the same as with
queries or to achieve the same thing with the geo_shape query ?

The document mapping:
{
"vehicle": {
"properties": {
"id": {
"type": "long"
},
"label": {
"type": "string"
},
"model": {
"type": "string"
},
"dealer": {
"type": "object",
"properties": {
"id": {
"type": "long"
},
"location": {
"type": "geo_point"
}
}
}
}
}
}

The query:
{
"query": {
"match_all": {}
},
"filter": {
"geo_distance": {
"distance": "200km",
"pin.location": {
"lat": 40,
"lon": -70
}
}
},
"facets": {
"models": {
"terms": {
"field": "model"
}
}
}
}

Here the model facet returns the same count as if we remove the filter.

I will really appreciate your help.

Regards,

--
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.

It's working perfectly. Thanks you Alex for your clear explanation :slight_smile:

Regards,

On Wednesday, May 22, 2013 11:10:06 AM UTC+2, Alexander Reelsen wrote:

Hey,

if you want the facets to use the filter, use a filtered query inside of
your "query" field which incorporates the "filter" field. A top level
filter is never used for facets. Alternatively you can also add facet
filters to your facet query in order to reduce results.

Hope this helps.

--Alex

On Wed, May 22, 2013 at 10:57 AM, Mehrez Marouani <mehrez....@gmail.com<javascript:>

wrote:

Hi,

I'm using the geo_distance filter to lookup a list of vehicle dealers
within a radius starting from a GeoPoint location.
The problem is that the returned terms facets ignore the filter and
return the whole count.
Is there any way to get the facets aware of the filters the same as with
queries or to achieve the same thing with the geo_shape query ?

The document mapping:
{
"vehicle": {
"properties": {
"id": {
"type": "long"
},
"label": {
"type": "string"
},
"model": {
"type": "string"
},
"dealer": {
"type": "object",
"properties": {
"id": {
"type": "long"
},
"location": {
"type": "geo_point"
}
}
}
}
}
}

The query:
{
"query": {
"match_all": {}
},
"filter": {
"geo_distance": {
"distance": "200km",
"pin.location": {
"lat": 40,
"lon": -70
}
}
},
"facets": {
"models": {
"terms": {
"field": "model"
}
}
}
}

Here the model facet returns the same count as if we remove the filter.

I will really appreciate your help.

Regards,

--
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 elasticsearc...@googlegroups.com <javascript:>.
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.