Geo search within country or continent


(mfriedma) #1

I'm new to elasticsearch. Thank you for this great product.

Our client would like to search within a region (continent), or within a
country, or even near a city.

I have been reading about geo shapes etc. I'm trying to find out if there
are any predefined shapes.

Are there predefined shapes for countries and continents within which we
would search?

What strategies would one use to find all of the 'X' within North America
for instance? (where X is something like 'Widget shops' and we have all the
pins indexed for those shops)

Many thanks.

Matt

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


(Ivan Brusic) #2

Instead of using geo queries, I would simply tag content with their
respective geographical/political attributes. At index time, come up with a
way to find where each widget shop is located and add an appropriate field.

Geo queries are expensive and are better suited for queries around some
dynamic point. Your data and queries are primarily static. If you index the
correct attributes are indexing time, you are only doing the lookup once.

Cheers,

Ivan

On Thu, Sep 5, 2013 at 12:08 PM, mfriedma@afilias.info wrote:

I'm new to elasticsearch. Thank you for this great product.

Our client would like to search within a region (continent), or within a
country, or even near a city.

I have been reading about geo shapes etc. I'm trying to find out if there
are any predefined shapes.

Are there predefined shapes for countries and continents within which we
would search?

What strategies would one use to find all of the 'X' within North America
for instance? (where X is something like 'Widget shops' and we have all the
pins indexed for those shops)

Many thanks.

Matt

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


(Jilles van Gurp) #3

First, if you can simply attach country and state codes to your data set,
that would be your best option really. That would enable you to use simple
term queries to do your searches which are about as fast as it gets in ES.

If you can't, you may want to look into getting your hands on a decent data
set with actual polygons for the areas you are interested in. Your best bet
for good shapes is quatroshapes. This is a curated dataset by Foursquare
with polygons for neighborhoods, cities, states, countries. A bit of a
warning though: this is a very messy dataset. Expect inconsistency, errors,
and worse.

It comes in the form of shape files; which elasticsearch does not handle
currently.

To fix that, use a tool called ogr2ogr to convert shape files to geojson.
Ogr2ogr is part of gdal, which is a set of gis commandline tools.

For example this command converts the quatroshapes neighborhood file while
also applying a simplification algorithm. You need the latter because ES
does not handle e.g. self intersecting polygons and several other common
problems with polygons.

ogr2ogr -wrapdateline -simplify 0.0005 -f geoJSON qs_neighborhoods.json
qs_neighborhoods.shp

Jilles

On Thursday, September 5, 2013 9:08:51 PM UTC+2, mfri...@afilias.info wrote:

I'm new to elasticsearch. Thank you for this great product.

Our client would like to search within a region (continent), or within a
country, or even near a city.

I have been reading about geo shapes etc. I'm trying to find out if there
are any predefined shapes.

Are there predefined shapes for countries and continents within which we
would search?

What strategies would one use to find all of the 'X' within North America
for instance? (where X is something like 'Widget shops' and we have all the
pins indexed for those shops)

Many thanks.

Matt

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


(mfriedma) #4

Very helpful answers. Thank you Ivan and Jilles.
Cheers, Matt

On Tue, Sep 10, 2013 at 4:49 AM, Jilles van Gurp jillesvangurp@gmail.comwrote:

First, if you can simply attach country and state codes to your data set,
that would be your best option really. That would enable you to use simple
term queries to do your searches which are about as fast as it gets in ES.

If you can't, you may want to look into getting your hands on a decent
data set with actual polygons for the areas you are interested in. Your
best bet for good shapes is quatroshapes. This is a curated dataset by
Foursquare with polygons for neighborhoods, cities, states, countries. A
bit of a warning though: this is a very messy dataset. Expect
inconsistency, errors, and worse.

It comes in the form of shape files; which elasticsearch does not handle
currently.

To fix that, use a tool called ogr2ogr to convert shape files to geojson.
Ogr2ogr is part of gdal, which is a set of gis commandline tools.

For example this command converts the quatroshapes neighborhood file while
also applying a simplification algorithm. You need the latter because ES
does not handle e.g. self intersecting polygons and several other common
problems with polygons.

ogr2ogr -wrapdateline -simplify 0.0005 -f geoJSON qs_neighborhoods.json
qs_neighborhoods.shp

Jilles

On Thursday, September 5, 2013 9:08:51 PM UTC+2, mfri...@afilias.infowrote:

I'm new to elasticsearch. Thank you for this great product.

Our client would like to search within a region (continent), or within a
country, or even near a city.

I have been reading about geo shapes etc. I'm trying to find out if there
are any predefined shapes.

Are there predefined shapes for countries and continents within which we
would search?

What strategies would one use to find all of the 'X' within North America
for instance? (where X is something like 'Widget shops' and we have all the
pins indexed for those shops)

Many thanks.

Matt

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


(system) #5