Hi Emir

I’ve been following one of the only examples I could find on how to index a 
POLYGON, which does specify the field as multiValued:

Configuration: schema.xml
<field name=“geo_rpt” type=“location_rpt”
  multiValued=“true” />
<fieldType name="location_rpt”
  class="solr.RptWithGeometrySpatialField”
  spatialContextFactory=
  ”
  spatialContextFactory=
  ”
  ”org.locationtech.spatial4j.context.jts.
    JtsSpatialContextFactory
    JtsSpatialContextFactory"  
  distanceUnits=”kilometers” autoIndex="true” 
  distErrPct="0.025” maxDistErr="0.000009” /> 
  distanceUnits=”kilometers” autoIndex="true”
  distErrPct="0.025” maxDistErr="0.000009” /> 
Index a polygon (JavaScript syntax around WKT):
{"id":"1", "geo_rpt":
"POLYGON((30 10, 10 20, 20 40, 40 40, 30 10))”}

Indexing one MULTIPOLYGON works also, but trying to enter them as a list like 
you would for any other multiValued field does not work. I couldn’t find 
explicitly that RptWithGeometrySpatialField supports multiValued, but according 
to the Solr docs, it is derived from SpatialRecursivePrefixTreeFieldType (RPT) 
which supports multiValued and is “configured just like RPT except that the 
default distErrPct is 0.15 (higher than 0.025)…”

The reason I’m trying to index multiple shapes per document is that in the 
index, each “layer” (document) has grid cells associated with it (they help 
describe the density of features across the layer; more density = smaller grid 
cells in an area). Indexing the grid cells will allow me to figure out how 
relevant a result for a search extent on a map might be; a layer could cover an 
entire country but be dense in major cities, so if I am looking for a major 
city, I’d want to boost this search result. Hope that makes sense. I’m not sure 
if flattening into a single shape would work for this purpose.

Thanks :)

> On 17/01/2018, at 10:12 PM, Emir Arnautović <emir.arnauto...@sematext.com> 
> wrote:
> 
> Hi Leila,
> I haven’t been using spatial in a while and did not test this, but based on 
> error, it seems that multivalue is not supported for this field type. Can you 
> index a single MULTIPOLYGON? Why do you need to have multiple values? Can you 
> flat your geometry to a single MULTIPOLYGON or MULTIGEOMETRY (if supported)? 
> Can you explain why do you need to have multiValued field?
> 
> Thanks,
> Emir
> --
> Monitoring - Log Management - Alerting - Anomaly Detection
> Solr & Elasticsearch Consulting Support Training - http://sematext.com/
> 
> 
> 
>> On 17 Jan 2018, at 00:09, Leila Deljkovic <leila.deljko...@koordinates.com> 
>> wrote:
>> 
>> Hi all,
>> 
>> I need to index multiple POLYGONS/MULTIPOLYGONS per document; I’m trying to 
>> use multiValued RptWithGeometrySpatialField and I’m getting this error:
>> 
>> Exception writing document id leila_test to the index; possible analysis 
>> error: DocValuesField "gridcell_rpt" appears more than once in this document 
>> (only one value is allowed per field)
>> 
>> This is what I’m indexing:
>> {
>>      "id": "leila_test",
>>      "gridcell_rpt": ["POLYGON((30 10, 10 20, 20 40, 40 40, 30 10))”, 
>> "MULTIPOLYGON(((30 20, 45 40, 10 40, 30 20)), ((15 5, 40 10, 10 20, 5 10, 15 
>> 5)))"]
>> }
>> 
>> This is what’s in my schema.xml:
>>      <field name=“gridcell_rpt” type=“location_rpt” multiValued=“true” />
>>      …
>>      <fieldType name=“location_rpt” class="solr.RptWithGeometrySpatialField”
>>      
>> spatialContextFactory="org.locationtech.spatial4j.context.jts.JtsSpatialContextFactory"
>>   
>>      distanceUnits=”kilometers” autoIndex="true”/>
>> 
>> I’m pretty confused on why this isn’t working. I can’t find an example of 
>> multiValued RptWithGeometrySpatialField anywhere -_-
>> 
>> Thanks :)
> 

Reply via email to