SOLR power shining through GeoServer OGC services
in this post we are going to introduce our latest development in terms of GeoServer data source: a SOLR based data store.
SOLR is a well known, fast, open source Java based search server, which can store documents in XML/JSON format and the allow for very quick searches on them. The documents can contain one or more fields, listed as part of the SOLR schema, and each document can contain any of the fields in the schema, one or more times.
One nice thing about SOLR is that it supports geometric fields, and can efficiently index them via a spatial indexing scheme, making it a suitable data source for GeoServer. The combination of SOLR and GeoServer is an interesting one, as it provides the speed and power of full SOLR searches for clients that can talk the protocol directly, an accessible OGC frontend for the rest of the world, and the ability to quickly depict and graphically summarize the document in a WMS map.
Now, you might wonder, how does one bind an un-structured document store to a OGC server, which uses a fixed data schema instead? Let’s see. First off, we connect the store by providing the url to the SOLR server, and identifying a document attribute that will be used to discriminate the available layers, and tell us which document is contained in which layer (given that documents are pretty flexible, adding a layer identifying attribute is normally not a problem):
Second, we choose one of the layer names identified by the layer_name_field:
Finally, choose which attributes available in the documents we want to take part in the feature type:
And voilà, the layer is ready for publishing, and ready for WMS serving:
It’s also worth noting that all filters GeoServer can receive via CQL_FILTER, OGC filter or SLDs are promptly turned into SOLR native query language, ensuring optimal data transfer, but just in case, if you have a filter that you cannot express using the normal GeoServer/OGC means, you can also pass down native “q” and “fq” filters, they can be provided as viewParams for this store. For example, the following can be added to the GetMap request:
3A"true"+AND+busPurpose%3A" Coal+seam+ methane"+AND+geo:" IsWithin(POLYGON((148.0%20-30. 0\,%20149.0%20-33.0\,%20150.5% 20-35.5\,%20152.4%20-32.6\, % 20151.0%20-30.7\,%20149.7%20- 29.6\,%20148.0%20-30.0)))"
We would like to thank the New South Wales Geological Survey for sponsoring this work, which was carried on as part of GeoSolutions Enterprise Support Services Plan.
The GeoSolutions team,