agarwal_achhnera
agarwal_achhnera

Reputation: 2456

how to search within a polygon in solr 4.10

Hi below is data xml which I have inserted in solr.

<add>
<doc>
  <field name="id">3007</field>
  <field name="name">Autauga</field>
  <field name="coord">POLYGON((-10 30,-40 40,-10 -20,40 20,0 0,-10 30))</field>
</doc>
</add>

There will be many documents of such type denoting separate regions Now please let me know How can I search that document having a given point which lies in the range of polygon.

Upvotes: 0

Views: 981

Answers (1)

user2894821
user2894821

Reputation: 186

Your Solr Version must be 4 or higher and you have to import the JTS jar-file. You also have to define a field with a fieldType of "solr.SpatialRecursivePrefixTreeFieldType". Then you can query using a filter query like fq=geo:"Intersects(10.12 50.02)".

But please see my previous post or http://wiki.apache.org/solr/SolrAdaptersForLuceneSpatial4 for more detailed information.

Upvotes: 1

Related Questions