Reputation: 477
Is there a way to search polygons which are inside another polygon with elasticsearch?
If not, is it possible with Solr or another system?
Upvotes: 2
Views: 1384
Reputation: 3787
Totally possible on Elasticsearch:
I'm just looking into implementing it myself, my only worry is performance on a high traffic site so we'll see what happens.
As this post was a while ago it would be interesting to know what you ended up doing...
Upvotes: 2
Reputation: 4141
With Solr 4.3 it just became possible; I just finished working on it a couple weeks ago and I'm pretty excited about it. To learn how to use the new Solr 4 spatial field, see: http://wiki.apache.org/solr/SolrAdaptersForLuceneSpatial4 What's new is that you can now use the "IsWithin" and "Contains" predicates; there's "IsDisjointTo" too. Based on your question, it's not clear to me which of those you want. Imagine a 3-part sentence in which the first/left part is your index data, then there's the spatial predicate, then there's your query shape. So if you want to search for indexed shapes that are WITHIN your query shape, then use "IsWithin". I was just about to update the wiki to show these predicates.
Upvotes: 1
Reputation: 18895
Pretty sure it's not possible with ES.
With Solr + some plugins I think it's possible, but haven't tried it myself. Have a look at https://github.com/spatial4j/spatial4j
Shape classes that are geospatially1 aware Shapes: Point, Rectangle, Circle, Polygon (via JTS) shape intersection logic, yielding: disjoint, contains, within, intersects bounding box area calculation
It seems spatial4J is already included in Solr. See David Smiley's response (author of Spatial4J and commiter to Solr) in the below link How to install spatial4j into solr4
Upvotes: 1