Search point in polygon

Hi,

I am looking for a solution for searching a point (lat/lon) in a polygon.
Currently I am able to find (indexed) polygons by specifying a bounding box
where the index polygon is in (with option WITHIN). But I need the
opposite. I indexed polygons in my documents. Now I want all documents back
based on query/filter with just a point (lat/lon). In other words give me
all the documents where a given point is withing the (indexed) polygons.

How can I do this with ES?

thx in advanced.

Maarten Janssen

--
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 should probably use intersects. The point intersects with the polygon.
As noted in my earlier post, within is disappearing from the API apparently.

Another trick is to convert the point into a circle polygon. I do this for
faking radius search. BTW. I have a library for doing stuff like this on
github: GitHub - jillesvangurp/geotools

Jilles

On Monday, March 4, 2013 12:16:42 PM UTC+1, Maarten Janssen wrote:

Hi,

I am looking for a solution for searching a point (lat/lon) in a polygon.
Currently I am able to find (indexed) polygons by specifying a bounding box
where the index polygon is in (with option WITHIN). But I need the
opposite. I indexed polygons in my documents. Now I want all documents back
based on query/filter with just a point (lat/lon). In other words give me
all the documents where a given point is withing the (indexed) polygons.

How can I do this with ES?

thx in advanced.

Maarten Janssen

--
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 Jilles,

Thx for your quick reply. I tried with intersects (and a point) without
luck. Even if I defined a point on the polygon line it won't find it.
I also was thinking about using a circle/rectangle but the problem than is
what should be the size of the circle? I mean it could be that multiple
polygones are part of the defined circle (or if my radius is to small I
still wouldn't find one).

thx for the library reference that is useful.

M

Op maandag 4 maart 2013 12:33:58 UTC+1 schreef Jilles van Gurp het volgende:

You should probably use intersects. The point intersects with the polygon.
As noted in my earlier post, within is disappearing from the API apparently.

Another trick is to convert the point into a circle polygon. I do this for
faking radius search. BTW. I have a library for doing stuff like this on
github: GitHub - jillesvangurp/geotools

Jilles

On Monday, March 4, 2013 12:16:42 PM UTC+1, Maarten Janssen wrote:

Hi,

I am looking for a solution for searching a point (lat/lon) in a polygon.
Currently I am able to find (indexed) polygons by specifying a bounding box
where the index polygon is in (with option WITHIN). But I need the
opposite. I indexed polygons in my documents. Now I want all documents back
based on query/filter with just a point (lat/lon). In other words give me
all the documents where a given point is withing the (indexed) polygons.

How can I do this with ES?

thx in advanced.

Maarten Janssen

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

Right, one hack here is to just use a really small circle (1 meter or so,
or even less). Polygon borders tend to be not very exact anyway and it an
error margin of one meter should be manageable.

Jilles

On Monday, March 4, 2013 1:03:29 PM UTC+1, Maarten Janssen wrote:

Hi Jilles,

Thx for your quick reply. I tried with intersects (and a point) without
luck. Even if I defined a point on the polygon line it won't find it.
I also was thinking about using a circle/rectangle but the problem than is
what should be the size of the circle? I mean it could be that multiple
polygones are part of the defined circle (or if my radius is to small I
still wouldn't find one).

thx for the library reference that is useful.

M

Op maandag 4 maart 2013 12:33:58 UTC+1 schreef Jilles van Gurp het
volgende:

You should probably use intersects. The point intersects with the
polygon. As noted in my earlier post, within is disappearing from the API
apparently.

Another trick is to convert the point into a circle polygon. I do this
for faking radius search. BTW. I have a library for doing stuff like this
on github: GitHub - jillesvangurp/geotools

Jilles

On Monday, March 4, 2013 12:16:42 PM UTC+1, Maarten Janssen wrote:

Hi,

I am looking for a solution for searching a point (lat/lon) in a
polygon. Currently I am able to find (indexed) polygons by specifying a
bounding box where the index polygon is in (with option WITHIN). But I need
the opposite. I indexed polygons in my documents. Now I want all documents
back based on query/filter with just a point (lat/lon). In other words give
me all the documents where a given point is withing the (indexed) polygons.

How can I do this with ES?

thx in advanced.

Maarten Janssen

--
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 Jilles,

I don't think the small circle is a solution that will work (or I miss the
point literally :)). First of all the circle shape is not (yet) supported I
guess in geo shape filtering. Secondly I don't see how a small circle will
work with WITHIN or INTERSECTS. The use case is: give me all the docs with
a polygon where the given input (search) point is part of. I think its the
opposite of the WITHIN because this will take the search shape as the shape
WITHIN the indexed documents should occur...

thus currently supported: indexed shape WITHIN filtered shape. I am
looking for: filtered shape/point WITHIN indexed shape.

The INTERSECTS looks only to shapes that are partly (overlap) covered..if I
try to build a small rectangle that is completely part of a polygon it
gives no results with INTERSECTS. See example below

INDEXED:
{"shape":{"location":{"type":"Polygon","coordinates":[[[2.0,1.0],[2.0,2.0],[1.0,2.0],[1.0,1.0],[2.0,1.0]]]},"text":"This
is my first test polygon"}}
SEARCH:
{
"filtered" : {
"query" : {
"match_all" : { }
},
"filter" : {
"geo_shape" : {
"location" : {
"relation" : "intersects",
"shape" : {
"type" : "Envelope",
"coordinates" : [ [ 1.5, 1.5 ], [ 1.6, 1.4 ] ]
}
},
"_name" : null
}
}
}
}

If I stretch the envelop to be out of the indexed polygon INTERSECTS is
working. Thus intersects only works if its part and not be part of the
indexed polygon

of course could be that your solution will work but I miss the point.

M

On Mon, Mar 4, 2013 at 2:27 PM, Jilles van Gurp jillesvangurp@gmail.comwrote:

Right, one hack here is to just use a really small circle (1 meter or so,
or even less). Polygon borders tend to be not very exact anyway and it an
error margin of one meter should be manageable.

Jilles

On Monday, March 4, 2013 1:03:29 PM UTC+1, Maarten Janssen wrote:

Hi Jilles,

Thx for your quick reply. I tried with intersects (and a point) without
luck. Even if I defined a point on the polygon line it won't find it.
I also was thinking about using a circle/rectangle but the problem than
is what should be the size of the circle? I mean it could be that multiple
polygones are part of the defined circle (or if my radius is to small I
still wouldn't find one).

thx for the library reference that is useful.

M

Op maandag 4 maart 2013 12:33:58 UTC+1 schreef Jilles van Gurp het
volgende:

You should probably use intersects. The point intersects with the
polygon. As noted in my earlier post, within is disappearing from the API
apparently.

Another trick is to convert the point into a circle polygon. I do this
for faking radius search. BTW. I have a library for doing stuff like this
on github: https://github.com/**jillesvangurp/geotoolshttps://github.com/jillesvangurp/geotools

Jilles

On Monday, March 4, 2013 12:16:42 PM UTC+1, Maarten Janssen wrote:

Hi,

I am looking for a solution for searching a point (lat/lon) in a
polygon. Currently I am able to find (indexed) polygons by specifying a
bounding box where the index polygon is in (with option WITHIN). But I need
the opposite. I indexed polygons in my documents. Now I want all documents
back based on query/filter with just a point (lat/lon). In other words give
me all the documents where a given point is withing the (indexed) polygons.

How can I do this with ES?

thx in advanced.

Maarten Janssen

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

--
Maarten Janssen
CTO Infohubble

Email: mjanssen@infohubble.com
URL: www.infohubble.com
Mobile: +31620006790
Card: eee.am/mjanssen

Address:

Infohubble BV
Gebouw Sevilla
Entrada 304
1096 ED Amsterdam
The Netherlands

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

Ah sorry, I should have been more clear.

I actually convert the circle into a polygon using my library. I have a
feature in there to do that. So, basically you end up with a circle like
polygon (you can specify the number of segments you want) and intersect
works great when you are intersecting two polygons.

I agree it is a bit of a hack though. But it is a good way to work around
some limitations. I originally intended to use this library to index
geohashes. This was before I figured out that Elasticsearch had evolved to
support polygons. So there's a lot of functionality in there to work with
all sorts of shapes and geohashes.

Jilles

On Monday, March 4, 2013 12:16:42 PM UTC+1, Maarten Janssen wrote:

Hi,

I am looking for a solution for searching a point (lat/lon) in a polygon.
Currently I am able to find (indexed) polygons by specifying a bounding box
where the index polygon is in (with option WITHIN). But I need the
opposite. I indexed polygons in my documents. Now I want all documents back
based on query/filter with just a point (lat/lon). In other words give me
all the documents where a given point is withing the (indexed) polygons.

How can I do this with ES?

thx in advanced.

Maarten Janssen

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

Ok thx but still I have doubts this will work for my use case. The real use
case is that I have described cities, municipalities and so on in polygons.
Based on a point (part of street/address) I want to search for the
corresponding city, municipality and country. I think the circle approach
wouldnt help me. There is a workaround by search for each polygons all
points (that works) but the use case I want to implement is more easy for
getting the information I need.

M

On Mon, Mar 4, 2013 at 5:23 PM, Jilles van Gurp jillesvangurp@gmail.comwrote:

Ah sorry, I should have been more clear.

I actually convert the circle into a polygon using my library. I have a
feature in there to do that. So, basically you end up with a circle like
polygon (you can specify the number of segments you want) and intersect
works great when you are intersecting two polygons.

I agree it is a bit of a hack though. But it is a good way to work around
some limitations. I originally intended to use this library to index
geohashes. This was before I figured out that Elasticsearch had evolved to
support polygons. So there's a lot of functionality in there to work with
all sorts of shapes and geohashes.

Jilles

On Monday, March 4, 2013 12:16:42 PM UTC+1, Maarten Janssen wrote:

Hi,

I am looking for a solution for searching a point (lat/lon) in a polygon.
Currently I am able to find (indexed) polygons by specifying a bounding box
where the index polygon is in (with option WITHIN). But I need the
opposite. I indexed polygons in my documents. Now I want all documents back
based on query/filter with just a point (lat/lon). In other words give me
all the documents where a given point is withing the (indexed) polygons.

How can I do this with ES?

thx in advanced.

Maarten Janssen

--
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/bDUQKTK0oe0/unsubscribe?hl=en-US
.
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.

--
Maarten Janssen
CTO Infohubble

Email: mjanssen@infohubble.com
URL: www.infohubble.com
Mobile: +31620006790
Card: eee.am/mjanssen

Address:

Infohubble BV
Gebouw Sevilla
Entrada 304
1096 ED Amsterdam
The Netherlands

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

Ah, you are trying to do a reverse geo coder. That's actually very similar
to what I'm doing. I'm about to index a lot of open street map data for
Berlin in the next few days to test this in a bit more detail. Basically
given a polygon for Berlin and Amsterdam and a coordinate, you basically
look for polygons that intersect with the 1m radius circle for your
coordinate. Assuming the coordinate is somewhere in berlin, that would mean
berlin intersects with that circle and the result set would include that
but not Amsterdam.

Jilles

On Monday, March 4, 2013 5:37:42 PM UTC+1, Maarten Janssen wrote:

Ok thx but still I have doubts this will work for my use case. The real
use case is that I have described cities, municipalities and so on in
polygons. Based on a point (part of street/address) I want to search for
the corresponding city, municipality and country. I think the circle
approach wouldnt help me. There is a workaround by search for each polygons
all points (that works) but the use case I want to implement is more easy
for getting the information I need.

M

On Mon, Mar 4, 2013 at 5:23 PM, Jilles van Gurp <jilles...@gmail.com<javascript:>

wrote:

Ah sorry, I should have been more clear.

I actually convert the circle into a polygon using my library. I have a
feature in there to do that. So, basically you end up with a circle like
polygon (you can specify the number of segments you want) and intersect
works great when you are intersecting two polygons.

I agree it is a bit of a hack though. But it is a good way to work around
some limitations. I originally intended to use this library to index
geohashes. This was before I figured out that Elasticsearch had evolved to
support polygons. So there's a lot of functionality in there to work with
all sorts of shapes and geohashes.

Jilles

On Monday, March 4, 2013 12:16:42 PM UTC+1, Maarten Janssen wrote:

Hi,

I am looking for a solution for searching a point (lat/lon) in a
polygon. Currently I am able to find (indexed) polygons by specifying a
bounding box where the index polygon is in (with option WITHIN). But I need
the opposite. I indexed polygons in my documents. Now I want all documents
back based on query/filter with just a point (lat/lon). In other words give
me all the documents where a given point is withing the (indexed) polygons.

How can I do this with ES?

thx in advanced.

Maarten Janssen

--
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/bDUQKTK0oe0/unsubscribe?hl=en-US
.
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.

--
Maarten Janssen
CTO Infohubble

Email: mjan...@infohubble.com <javascript:>
URL: www.infohubble.com
Mobile: +31620006790
Card: eee.am/mjanssen

Address:

Infohubble BV
Gebouw Sevilla
Entrada 304
1096 ED Amsterdam
The Netherlands

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

Than I am happy to get your solution :slight_smile:

The thing is intersects works only (thats what I get out of my test
results) when 2 polygons have overlap. If one polygon is completely in the
other polygon it will not see this as an intersection/overlap.
So when you draw a circle (as a polygon) and do an INTERSECTS with the
polygon of Berlin the chances are really there the circle is completely
within the Berlin polygon and INTERSECTS wont give you Berlin back because
it doesn't hit a polygon boundary. It would be much cleaner if we just
could say give me all the documents where a given point is part of the
defined polygons.

M

On Mon, Mar 4, 2013 at 5:50 PM, Jilles van Gurp jillesvangurp@gmail.comwrote:

Ah, you are trying to do a reverse geo coder. That's actually very similar
to what I'm doing. I'm about to index a lot of open street map data for
Berlin in the next few days to test this in a bit more detail. Basically
given a polygon for Berlin and Amsterdam and a coordinate, you basically
look for polygons that intersect with the 1m radius circle for your
coordinate. Assuming the coordinate is somewhere in berlin, that would mean
berlin intersects with that circle and the result set would include that
but not Amsterdam.

Jilles

On Monday, March 4, 2013 5:37:42 PM UTC+1, Maarten Janssen wrote:

Ok thx but still I have doubts this will work for my use case. The real
use case is that I have described cities, municipalities and so on in
polygons. Based on a point (part of street/address) I want to search for
the corresponding city, municipality and country. I think the circle
approach wouldnt help me. There is a workaround by search for each polygons
all points (that works) but the use case I want to implement is more easy
for getting the information I need.

M

On Mon, Mar 4, 2013 at 5:23 PM, Jilles van Gurp jilles...@gmail.comwrote:

Ah sorry, I should have been more clear.

I actually convert the circle into a polygon using my library. I have a
feature in there to do that. So, basically you end up with a circle like
polygon (you can specify the number of segments you want) and intersect
works great when you are intersecting two polygons.

I agree it is a bit of a hack though. But it is a good way to work
around some limitations. I originally intended to use this library to index
geohashes. This was before I figured out that Elasticsearch had evolved to
support polygons. So there's a lot of functionality in there to work with
all sorts of shapes and geohashes.

Jilles

On Monday, March 4, 2013 12:16:42 PM UTC+1, Maarten Janssen wrote:

Hi,

I am looking for a solution for searching a point (lat/lon) in a
polygon. Currently I am able to find (indexed) polygons by specifying a
bounding box where the index polygon is in (with option WITHIN). But I need
the opposite. I indexed polygons in my documents. Now I want all documents
back based on query/filter with just a point (lat/lon). In other words give
me all the documents where a given point is withing the (indexed) polygons.

How can I do this with ES?

thx in advanced.

Maarten Janssen

--
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/**bDUQKTK0oe0/unsubscribe?hl=en-**UShttps://groups.google.com/d/topic/elasticsearch/bDUQKTK0oe0/unsubscribe?hl=en-US
.
To unsubscribe from this group and all its topics, send an email to
elasticsearc...@**googlegroups.com.
For more options, visit https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out
.

--
Maarten Janssen
CTO Infohubble

Email: mjan...@infohubble.com
URL: www.infohubble.com
Mobile: +31620006790
Card: eee.am/mjanssen

Address:

Infohubble BV
Gebouw Sevilla
Entrada 304
1096 ED Amsterdam
The Netherlands

--
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/bDUQKTK0oe0/unsubscribe?hl=en-US
.
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.

--
Maarten Janssen
CTO Infohubble

Email: mjanssen@infohubble.com
URL: www.infohubble.com
Mobile: +31620006790
Card: eee.am/mjanssen

Address:

Infohubble BV
Gebouw Sevilla
Entrada 304
1096 ED Amsterdam
The Netherlands

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

Hmm, I just tried this and it seems you are right. Very annoying. I guess
was assuming too much about intersects.

I guess you could turn things around and use a really large circle that for
sure includes all the polygons you care about and then do a filter on
polygon containment after you get the results. My library offers a contains
function. But that is far from ideal.

This sounds like it might be a bug though since technically a large feature
should intersect with any small feature contained by it.

Jilles

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

Or even better a new ShapeRelation should be produced called CONTAINS or
IS_PART_OF where you get do the other way around. In our case (I think we
need the same approach) we could go top down and match first all the
polygons, and then use indeed a contains method, but in my opnion it should
be part of the spatial search capabilities.

On Mon, Mar 4, 2013 at 6:33 PM, Jilles van Gurp jillesvangurp@gmail.comwrote:

Hmm, I just tried this and it seems you are right. Very annoying. I guess
was assuming too much about intersects.

I guess you could turn things around and use a really large circle that
for sure includes all the polygons you care about and then do a filter on
polygon containment after you get the results. My library offers a contains
function. But that is far from ideal.

This sounds like it might be a bug though since technically a large
feature should intersect with any small feature contained by it.

Jilles

--
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/bDUQKTK0oe0/unsubscribe?hl=en-US
.
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.

--
Maarten Janssen
CTO Infohubble

Email: mjanssen@infohubble.com
URL: www.infohubble.com
Mobile: +31620006790
Card: eee.am/mjanssen

Address:

Infohubble BV
Gebouw Sevilla
Entrada 304
1096 ED Amsterdam
The Netherlands

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

Actually, I was wrong again. I did make it work in the end.

If others want to replicate my experiment, I pasted a few sample queries
and responses as well as the data and mapping I indexed here:

The first query shows that a query with a circle of 1m radius returns
Berlin and Mitte for a circle near Rosenthalerplatz. So, the 1m circle
polygon intersects with both polygons that fully contain the circle polygon.

If I increase the radius to 300 meter it also finds the nearby pois. There
is a problem with accuracy though. I noticed that 100 meter doesn't return
any of the pois. even though I know that it should have returned a few. If
I increase to 150 it returns the Prenzlauerberg polygon but still no POIs.
At 157 still the same. At 158, I suddenly get 8 results.

I might be able to improve the accuracy by playing with the levels in the
mapping.

So what might be happening is that you are running into this accuracy issue
here as well. If you haven't already, upgrading to a post 0.90-beta1
snapshot build might help you. That would get you the changes made a few
days ago to the geo_shape implementation.

Jilles

On Monday, March 4, 2013 6:44:10 PM UTC+1, Maarten Janssen wrote:

Or even better a new ShapeRelation should be produced called CONTAINS or
IS_PART_OF where you get do the other way around. In our case (I think we
need the same approach) we could go top down and match first all the
polygons, and then use indeed a contains method, but in my opnion it should
be part of the spatial search capabilities.

On Mon, Mar 4, 2013 at 6:33 PM, Jilles van Gurp <jilles...@gmail.com<javascript:>

wrote:

Hmm, I just tried this and it seems you are right. Very annoying. I guess
was assuming too much about intersects.

I guess you could turn things around and use a really large circle that
for sure includes all the polygons you care about and then do a filter on
polygon containment after you get the results. My library offers a contains
function. But that is far from ideal.

This sounds like it might be a bug though since technically a large
feature should intersect with any small feature contained by it.

Jilles

--
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/bDUQKTK0oe0/unsubscribe?hl=en-US
.
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.

--
Maarten Janssen
CTO Infohubble

Email: mjan...@infohubble.com <javascript:>
URL: www.infohubble.com
Mobile: +31620006790
Card: eee.am/mjanssen

Address:

Infohubble BV
Gebouw Sevilla
Entrada 304
1096 ED Amsterdam
The Netherlands

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

Did you get this working in the end Maarten?

I have the same problem with the way 'intersects' works and Jilles's
solution doesn't work for me; possibly due to the 'tree_levels' accuracy
for quad tree.

As a kind of workaround, I was thinking that you could draw 2 'envelope'
geo_shape intersection; one vertical and one horizontal.
Using a boolean filter you could reduce your results to only the polygons
which intersect BOTH intersections.

It would look something like this:

https://lh3.googleusercontent.com/-NkNXyNjCLwQ/U6wBLrRIbNI/AAAAAAAAJkU/383LpZNwVzE/s1600/bbox.png

Here's an example of the query:

Unfortunately I couldn't get this working either, do you think this may be
a simpler workaround for the 'intersects' issue?

-P

On Tuesday, 5 March 2013 14:17:01 UTC+1, Jilles van Gurp wrote:

Actually, I was wrong again. I did make it work in the end.

If others want to replicate my experiment, I pasted a few sample queries
and responses as well as the data and mapping I indexed here:
sample es requests and responses with geo_shape - Pastebin.com

The first query shows that a query with a circle of 1m radius returns
Berlin and Mitte for a circle near Rosenthalerplatz. So, the 1m circle
polygon intersects with both polygons that fully contain the circle polygon.

If I increase the radius to 300 meter it also finds the nearby pois. There
is a problem with accuracy though. I noticed that 100 meter doesn't return
any of the pois. even though I know that it should have returned a few. If
I increase to 150 it returns the Prenzlauerberg polygon but still no POIs.
At 157 still the same. At 158, I suddenly get 8 results.

I might be able to improve the accuracy by playing with the levels in the
mapping.

So what might be happening is that you are running into this accuracy
issue here as well. If you haven't already, upgrading to a post 0.90-beta1
snapshot build might help you. That would get you the changes made a few
days ago to the geo_shape implementation.

Jilles

On Monday, March 4, 2013 6:44:10 PM UTC+1, Maarten Janssen wrote:

Or even better a new ShapeRelation should be produced called CONTAINS or
IS_PART_OF where you get do the other way around. In our case (I think we
need the same approach) we could go top down and match first all the
polygons, and then use indeed a contains method, but in my opnion it should
be part of the spatial search capabilities.

On Mon, Mar 4, 2013 at 6:33 PM, Jilles van Gurp jilles...@gmail.com
wrote:

Hmm, I just tried this and it seems you are right. Very annoying. I
guess was assuming too much about intersects.

I guess you could turn things around and use a really large circle that
for sure includes all the polygons you care about and then do a filter on
polygon containment after you get the results. My library offers a contains
function. But that is far from ideal.

This sounds like it might be a bug though since technically a large
feature should intersect with any small feature contained by it.

Jilles

--
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/bDUQKTK0oe0/unsubscribe?hl=en-US
.
To unsubscribe from this group and all its topics, send an email to
elasticsearc...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
Maarten Janssen
CTO Infohubble

Email: mjan...@infohubble.com
URL: www.infohubble.com
Mobile: +31620006790
Card: eee.am/mjanssen

Address:

Infohubble BV
Gebouw Sevilla
Entrada 304
1096 ED Amsterdam
The Netherlands

--
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/efa8d361-fc4f-46fb-9e99-d40910caa395%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.