Hi,
I got everything in place, my polygons are indexing properly, I played a
bit with LSP which helped me a lot, now, I have JTS 1.13 inside
solr.war; here is my challenge:
I have big polygon (A) which contains smaller polygons (B and C), B and
C have some intersection, so if I search for a coordinate inside the 3,
I would like to sort by the distance to the centre of the polygons that
match the criteria.
As example, let's say dot B is on the centre of B, dot C is at the
centre of C and dot A is at the intersection of B and C which happens to
be the centre of A, so for dot A should be polygon A first and so on. I
could compute with the distances using the result but since Solr is
doing a heavy load already, why not just include the sort in it.
Here is my field type definition:
<!-- Spatial field type -->
<fieldType name="location_rpt"
class="solr.SpatialRecursivePrefixTreeFieldType"
spatialContextFactory="com.spatial4j.core.context.jts.JtsSpatialContextFactory"
units="degrees"/>
Field definition:
<!-- JTS spatial polygon field -->
<field name="geopolygon" type="location_rpt" indexed="true"
stored="false" required="false" multiValued="true"/>
I'm using the Solr admin UI first to shape my query and then moving to
our web app which uses solrj, here is the XML form of my result which
includes the query I'm making, which scores all distances to 1.0 (Not
what I want):
|<?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">9</int>
<lst name="params">
<str name="fl">id,score</str>
<str name="sort">score asc</str>
<str name="indent">true</str>
<str name="q">*:*</str>
<str name="_">1366111120720</str>
<str name="wt">xml</str>
<str name="fq">{!score=distance}geopolygon:"Intersects(-6.271906
53.379284)"</str>
</lst>
</lst>
<result name="response" numFound="3" start="0" maxScore="1.0">
<doc>
<str name="id">uid13972</str>
<float name="score">1.0</float></doc>
<doc>
<str name="id">uid13979</str>
<float name="score">1.0</float></doc>
<doc>
<str name="id">uid13974</str>
<float name="score">1.0</float></doc>
</result>
</response>|
Thanks for all responses,
Guido.