Geo distance sort

Hi!

I´m working with 80.000 records but only 2000 of them have location. This
is my query:

$q = new \Elastica\Query\Builder('{
"from" : 0, "size" : 100,
"query":{"match_all" : { }},
"sort" : [
{"_geo_distance" : {
"location" : {
"lat" : -2.172273,
"lon" : 43.284734
},
"order" : "asc",
"unit" : "m"}
}
]
}');

how can I exclude those rows without location??

I need to obtain a list of shops withing 10km radio sorted by distance from
a given point.

Thanks in advance

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

Hi Iker,

You can use "geo distance filter".

See geo distance filter


Jun Ohtani
johtani@gmail.com
twitter : http://twitter.com/johtani

On 2013/09/24, at 23:19, Iker Ibarguren ikerib@gmail.com wrote:

Hi!

I´m working with 80.000 records but only 2000 of them have location. This is my query:

$q = new \Elastica\Query\Builder('{
"from" : 0, "size" : 100,
"query":{"match_all" : { }},
"sort" : [
{"_geo_distance" : {
"location" : {
"lat" : -2.172273,
"lon" : 43.284734
},
"order" : "asc",
"unit" : "m"}
}
]
}');

how can I exclude those rows without location??

I need to obtain a list of shops withing 10km radio sorted by distance from a given point.

Thanks in advance

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

but with the filter I don´t have the distance from my location to the shop.
(It will be a mobile app).

I tried this:

public function getgeocomercios2Action() {
$view = FOSView::create();
$finder =
$this->container->get('fos_elastica.finder.comercios.comercio');

    $q = new \Elastica\Query\Builder('{
        "query": {
                "filtered" : {
                    "query" : {
                        "match_all" : {}
                    },
                "filter" : {
                    "geo_distance" : {
                        "distance" : "100m",
                        "location" : {
                            "lat" : -2.1741771697998047,
                            "lon" : 43.28249657890983
                        }
                    }
                }
            }
        }

    }');

iKER

2013/9/24 Jun Ohtani johtani@gmail.com

Hi Iker,

You can use "geo distance filter".

See geo distance filter
Elasticsearch Platform — Find real-time answers at scale | Elastic


Jun Ohtani
johtani@gmail.com
twitter : http://twitter.com/johtani

On 2013/09/24, at 23:19, Iker Ibarguren ikerib@gmail.com wrote:

Hi!

I´m working with 80.000 records but only 2000 of them have location.
This is my query:

$q = new \Elastica\Query\Builder('{
"from" : 0, "size" : 100,
"query":{"match_all" : { }},
"sort" : [
{"_geo_distance" : {
"location" : {
"lat" : -2.172273,
"lon" : 43.284734
},
"order" : "asc",
"unit" : "m"}
}
]
}');

how can I exclude those rows without location??

I need to obtain a list of shops withing 10km radio sorted by distance
from a given point.

Thanks in advance

--
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 a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/QsXBWpNyI08/unsubscribe.
To unsubscribe from this group and all its topics, 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.

Hi Iker,

Oh sorry.
You should use "exists filter".

Like this.

{
"query": {
"filtered": {
"query": {
"matchAll": {}
},
"filter": {
"exists": {
"field": "location"
}
}
}
},
"sort": [
{
"_geo_distance": {
"location": {
"lat": -2.172273,
"lon": 43.284734
},
"order": "asc",
"unit": "m"
}
}
]
}


Jun Ohtani
johtani@gmail.com
twitter : http://twitter.com/johtani

On 2013/09/24, at 23:52, iKER- ikerib@gmail.com wrote:

but with the filter I don´t have the distance from my location to the shop. (It will be a mobile app).

I tried this:

public function getgeocomercios2Action() {
$view = FOSView::create();
$finder = $this->container->get('fos_elastica.finder.comercios.comercio');

    $q = new \Elastica\Query\Builder('{
        "query": {
                "filtered" : {
                    "query" : {
                        "match_all" : {}
                    },
                "filter" : {
                    "geo_distance" : {
                        "distance" : "100m",
                        "location" : {
                            "lat" : -2.1741771697998047,
                            "lon" : 43.28249657890983
                        }
                    }
                }
            }
        }

    }');

iKER

2013/9/24 Jun Ohtani johtani@gmail.com
Hi Iker,

You can use "geo distance filter".

See geo distance filter
Elasticsearch Platform — Find real-time answers at scale | Elastic


Jun Ohtani
johtani@gmail.com
twitter : http://twitter.com/johtani

On 2013/09/24, at 23:19, Iker Ibarguren ikerib@gmail.com wrote:

Hi!

I´m working with 80.000 records but only 2000 of them have location. This is my query:

$q = new \Elastica\Query\Builder('{
"from" : 0, "size" : 100,
"query":{"match_all" : { }},
"sort" : [
{"_geo_distance" : {
"location" : {
"lat" : -2.172273,
"lon" : 43.284734
},
"order" : "asc",
"unit" : "m"}
}
]
}');

how can I exclude those rows without location??

I need to obtain a list of shops withing 10km radio sorted by distance from a given point.

Thanks in advance

--
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 a topic in the Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elasticsearch/QsXBWpNyI08/unsubscribe.
To unsubscribe from this group and all its topics, 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.

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

ooooohh oh!! thx!! :wink:

On Tuesday, September 24, 2013 5:12:30 PM UTC+2, Jun Ohtani wrote:

Hi Iker,

Oh sorry.
You should use "exists filter".
Elasticsearch Platform — Find real-time answers at scale | Elastic

Like this.

{
"query": {
"filtered": {
"query": {
"matchAll": {}
},
"filter": {
"exists": {
"field": "location"
}
}
}
},
"sort": [
{
"_geo_distance": {
"location": {
"lat": -2.172273,
"lon": 43.284734
},
"order": "asc",
"unit": "m"
}
}
]
}


Jun Ohtani
joh...@gmail.com <javascript:>
twitter : http://twitter.com/johtani

On 2013/09/24, at 23:52, iKER- <ike...@gmail.com <javascript:>> wrote:

but with the filter I don´t have the distance from my location to the
shop. (It will be a mobile app).

I tried this:

public function getgeocomercios2Action() {
$view = FOSView::create();
$finder =
$this->container->get('fos_elastica.finder.comercios.comercio');

    $q = new \Elastica\Query\Builder('{ 
        "query": { 
                "filtered" : { 
                    "query" : { 
                        "match_all" : {} 
                    }, 
                "filter" : { 
                    "geo_distance" : { 
                        "distance" : "100m", 
                        "location" : { 
                            "lat" : -2.1741771697998047, 
                            "lon" : 43.28249657890983 
                        } 
                    } 
                } 
            } 
        } 

    }'); 

iKER

2013/9/24 Jun Ohtani <joh...@gmail.com <javascript:>>
Hi Iker,

You can use "geo distance filter".

See geo distance filter

Elasticsearch Platform — Find real-time answers at scale | Elastic


Jun Ohtani
joh...@gmail.com <javascript:>
twitter : http://twitter.com/johtani

On 2013/09/24, at 23:19, Iker Ibarguren <ike...@gmail.com <javascript:>>
wrote:

Hi!

I´m working with 80.000 records but only 2000 of them have location.
This is my query:

$q = new \Elastica\Query\Builder('{
"from" : 0, "size" : 100,
"query":{"match_all" : { }},
"sort" : [
{"_geo_distance" : {
"location" : {
"lat" : -2.172273,
"lon" : 43.284734
},
"order" : "asc",
"unit" : "m"}
}
]
}');

how can I exclude those rows without location??

I need to obtain a list of shops withing 10km radio sorted by distance
from a given point.

Thanks in advance

--
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 a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/QsXBWpNyI08/unsubscribe.
To unsubscribe from this group and all its topics, 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 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.