You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Jan Nekuda <ja...@gmail.com> on 2016/04/22 10:33:38 UTC

Solr - index polygons from csv

Hello guys,
I use solr 6 for indexing data with points and polygons.

I have a question about indexing polygons from csv file. I have configured
type:
<fieldType name="location_rpt"
class="solr.SpatialRecursivePrefixTreeFieldType" geo="false"
maxDistErr="0.001" worldBounds="ENVELOPE(-100000000,-1,-1,-100000000)"
distErrPct="0.025" distanceUnits="kilometers"/>

and field
<field name="polygon_mapa" type="location_rpt" indexed="true"
stored="true"/>

I have tried to import this csv:
kod_adresa,nazev_ulice,cislo_orientacni,cislo_domovni,polygon_mapa,nazev_obec,Nazev_cast_obce,kod_ulice,kod_cast_obce,kod_obec,kod_momc,nazev_momc,Nazev,psc,nazev_vusc,kod_vusc,Nazev_okres,Kod_okres
999999999,,,4,"POLYGON ((-30 -10,-10 -20,-20 -40,-40 -40,-30
-10))",Vacov,Javorník,,57843,550621,,,Stachy,38473,Jihočeský
kraj,35,Prachatice,3306

and result is:

Posting files to [base] url http://localhost:8983/solr/ruian/update...
Entering auto mode. File endings considered are
xml,json,jsonl,csv,pdf,doc,docx,ppt,pptx,xls,xlsx,odt,odp,ods,ott,otp,ots,rtf,htm,html,txt,log
POSTing file polygon.csv (text/csv) to [base]
SimplePostTool: WARNING: Solr returned an error #400 (Bad Request) for url:
http://localhost:8983/solr/ruian/update
SimplePostTool: WARNING: Response: <?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="responseHeader"><int name="status">400</int><int
name="QTime">3</int></lst><lst name="error"><lst name="metadata"><str
name="error-class">org.apache.solr.common.SolrException</str><str
name="root-error-class">java.lang.UnsupportedOperationException</str></lst><str
name="msg">Couldn't parse shape 'POLYGON ((-30 -10,-10 -20,-20 -40,-40
-40,-30 -10))' because: java.lang.UnsupportedOperationException:
Unsupported shape of this SpatialContext. Try JTS or Geo3D.</str><int
name="code">400</int></lst>
</response>
SimplePostTool: WARNING: IOException while reading response:
java.io.IOException: Server returned HTTP response code: 400 for URL:
http://localhost:8983/solr/ruian/update
1 files indexed.
COMMITting Solr index changes to http://localhost:8983/solr/ruian/update...
Time spent: 0:00:00.036

Could someone give me any advice how to solve it? With indexing points in
the same way I'm fine.

and one more question:
I have this field type:
 <fieldType name="location_rpt"
class="solr.SpatialRecursivePrefixTreeFieldType"* geo="false*"
maxDistErr="0.001"
worldBounds="ENVELOPE(-100000000,-1,-1,-100000000)" distErrPct="0.025"
distanceUnits="kilometers"/>

if I use  geo=false for solr.SpatialRecursivePrefixTreeFieldType and I use
this query:
http://localhost:8983/solr/ruian/select?indent=on&q=*:*&fq={!bbox%20sfield=mapa}&pt=-818044.37%20-1069122.12&d=200000
<http://localhost:8983/solr/ruian/select?indent=on&q=*:*&fq=%7B!bbox%20sfield=mapa%7D&pt=-818044.37%20-1069122.12&d=200000>
for
getting all object in distance. But I actually don't know in which units
the distance is with this settings.



Thank you very much

Jan

Re: Solr - index polygons from csv

Posted by David Smiley <da...@gmail.com>.
Hi.

To use polygons, you need to add JTS, otherwise you get an unsupported
shape error.  See
https://cwiki.apache.org/confluence/display/solr/Apache+Solr+Reference+Guide
it involves not only adding a JTS lib to your classpath (ideal spot is
WEB-INF/lib ) but also adding a spatialContextFactory attribute.  Note that
the value of this attribute is different from 6.0 forward (as seen on the
live page), so get a PDF copy of the ref guide matching the Solr version
you are using if you are not on the latest.  Also, I recommend using
solr.RptWithGeometrySpatialField for indexing non-point data (and it'll
probably work fine for point data too).

When you use geo=false, there are no units or it might have an ignorable
value of degrees.  Essentially it's in whatever units your data is on the
Euclidean 2D plane.

~ David

On Fri, Apr 22, 2016 at 4:33 AM Jan Nekuda <ja...@gmail.com> wrote:

> Hello guys,
> I use solr 6 for indexing data with points and polygons.
>
> I have a question about indexing polygons from csv file. I have configured
> type:
> <fieldType name="location_rpt"
> class="solr.SpatialRecursivePrefixTreeFieldType" geo="false"
> maxDistErr="0.001" worldBounds="ENVELOPE(-100000000,-1,-1,-100000000)"
> distErrPct="0.025" distanceUnits="kilometers"/>
>
> and field
> <field name="polygon_mapa" type="location_rpt" indexed="true"
> stored="true"/>
>
> I have tried to import this csv:
>
> kod_adresa,nazev_ulice,cislo_orientacni,cislo_domovni,polygon_mapa,nazev_obec,Nazev_cast_obce,kod_ulice,kod_cast_obce,kod_obec,kod_momc,nazev_momc,Nazev,psc,nazev_vusc,kod_vusc,Nazev_okres,Kod_okres
> 999999999,,,4,"POLYGON ((-30 -10,-10 -20,-20 -40,-40 -40,-30
> -10))",Vacov,Javorník,,57843,550621,,,Stachy,38473,Jihočeský
> kraj,35,Prachatice,3306
>
> and result is:
>
> Posting files to [base] url http://localhost:8983/solr/ruian/update...
> Entering auto mode. File endings considered are
>
> xml,json,jsonl,csv,pdf,doc,docx,ppt,pptx,xls,xlsx,odt,odp,ods,ott,otp,ots,rtf,htm,html,txt,log
> POSTing file polygon.csv (text/csv) to [base]
> SimplePostTool: WARNING: Solr returned an error #400 (Bad Request) for url:
> http://localhost:8983/solr/ruian/update
> SimplePostTool: WARNING: Response: <?xml version="1.0" encoding="UTF-8"?>
> <response>
> <lst name="responseHeader"><int name="status">400</int><int
> name="QTime">3</int></lst><lst name="error"><lst name="metadata"><str
> name="error-class">org.apache.solr.common.SolrException</str><str
>
> name="root-error-class">java.lang.UnsupportedOperationException</str></lst><str
> name="msg">Couldn't parse shape 'POLYGON ((-30 -10,-10 -20,-20 -40,-40
> -40,-30 -10))' because: java.lang.UnsupportedOperationException:
> Unsupported shape of this SpatialContext. Try JTS or Geo3D.</str><int
> name="code">400</int></lst>
> </response>
> SimplePostTool: WARNING: IOException while reading response:
> java.io.IOException: Server returned HTTP response code: 400 for URL:
> http://localhost:8983/solr/ruian/update
> 1 files indexed.
> COMMITting Solr index changes to http://localhost:8983/solr/ruian/update.
> ..
> Time spent: 0:00:00.036
>
> Could someone give me any advice how to solve it? With indexing points in
> the same way I'm fine.
>
> and one more question:
> I have this field type:
>  <fieldType name="location_rpt"
> class="solr.SpatialRecursivePrefixTreeFieldType"* geo="false*"
> maxDistErr="0.001"
> worldBounds="ENVELOPE(-100000000,-1,-1,-100000000)" distErrPct="0.025"
> distanceUnits="kilometers"/>
>
> if I use  geo=false for solr.SpatialRecursivePrefixTreeFieldType and I use
> this query:
>
> http://localhost:8983/solr/ruian/select?indent=on&q=*:*&fq={!bbox%20sfield=mapa}&pt=-818044.37%20-1069122.12&d=200000
> <http://localhost:8983/solr/ruian/select?indent=on&q=*:*&fq=%7B!bbox%20sfield=mapa%7D&pt=-818044.37%20-1069122.12&d=200000>
> <
> http://localhost:8983/solr/ruian/select?indent=on&q=*:*&fq=%7B!bbox%20sfield=mapa%7D&pt=-818044.37%20-1069122.12&d=200000
> >
> for
> getting all object in distance. But I actually don't know in which units
> the distance is with this settings.
>
>
>
> Thank you very much
>
> Jan
>
-- 
Lucene/Solr Search Committer, Consultant, Developer, Author, Speaker
LinkedIn: http://linkedin.com/in/davidwsmiley | Book:
http://www.solrenterprisesearchserver.com