Hello all,
in our company we use with success GeoServer and Apache Solr for several project, but never togheter, so we tried to realize a proof of concept to demonstrate that solr can be a good choice as data for lat/lon positions managed by one of our projects (we are talking of the order of magnitude of about two MILLION or more positions stored).
We followed the guide that we found at: http://docs.geoserver.org/latest/en/user/community/solr/index.html
so we downloaded version 2.7-SNAPSHOT of GeoServer due to the fact that the guide is intended for 2.7.x versions.
We’re using Solr version 4.10.3 (> than 4.8/4.9 written on the guide).
We downloaded and successfully installed solr extension from http://ares.boundlessgeo.com/geoserver/master/community-latest/ (we was able to see Solr as possible datasource in GS admin page).
Until now everithing seems to be ok, but we had to work hard to see that “beautiful” little red squares representing our positions on the world rectangle.
And here comes first problems:
adding the “layer” or “categorization” field to ALL our solr documents to satisfy the requirement of the plugin was not easy, but fortunately we was “playing” with solr, so we was able to delete all created documents a recreate them with an additional default field, in our case named “layer” which default value is “positions”, so when uploading new documents, if a value for field “layer” is not provided the default value “positions” is set. In Solr you can do this by defining a field in this way in schema.xml file:
In our case was not a problem redefine the schema, but would be great if the solr plugin of geoserver uses the “layer” field as optional filter field and not as mandatory feature the user documents must provide.
Always in schema.xml we have a field:
where location_rpt is a type defined as:
Remember that this is not the default “location_rpt” field that comes with solr in bundle, we added the spatialContextFactory attribute, but to avoid classNotFound exceptions on Solr startup you have to install Jts libraries inside your solr web-inf/lib directory inside the war.
Following various guide on the internet we found that rpt fields can be write on solr product in different format: we used “longitude latitude” (longitude first and latitude after separated by a space) format. (THIS IS WRONG, read below for correct solution)
All done Solr side… for now…
And here comes the pain… in solr field configuration whe defined locationRpt as a “Geometry” (but also with ALL other possible choices in drop-down menu) but nothing: various exceptions both on solr output console (while geoserver does spatial queries on it) and on geoserver console (wrong geometry errors).
The SOLUTION was to define positionRpt content in WKT syntax, so a document with lat and lon values must have the rpt field expressed as “POINT(latitude,longitude)”, this is the syntax to express a point in WKT language.
And voilà! everithing worked, we was able to see ALL our positions on the layer preview.
Hoping to be helpful
Bye
Francesco Fornari
Italian Software Engineer