.. _solr_tutorial: Apache Solr Tutorial ==================== This tutorial demonstrates how to use the App-Schema plugin with a Apache Solr data store. This tutorial will focus on the Apache Solr data store specific aspects, and the :ref:`App-Schema documentation ` should be read first. The use case for this tutorial will be to serve through App-Schema the information about some meteorological stations index in an Apache Solr core. Note that this use case is completely fictional and only used to demonstrate the Apache Solr and App-Schema integration. A station data is composed of some meta-information about the station, e.g. it's name and position. The only extra \ different configuration we need to provide when using Apache Solr as a data source is the configuration of the data store itself. Apache Solr data source configuration as a specific syntax and allow us to specify geometry attributes and to explicitly set the default geometry: .. code-block:: xml stations http://localhost:8983/solr/stations location 4326 POINT In this particular case the ``location`` attribute contains a point geometry and will be the default geometry. The complete mapping file is: .. code-block:: xml st http://www.stations.org/1.0 gml http://www.opengis.net/gml/3.2 stations http://localhost:8983/solr/stations location 4326 POINT stations.xsd stations_solr stations stations st:Station st:Station station_id st:stationName station_name st:position station_location The mappings for the attributes are straightforward and follow the normal App-Schema attributes mappings syntax. Currently multi valued fields are not supported. Using Solr as App-Schema Indexes -------------------------------- App-Schema Indexes is an extension for mapping that allows to use Apache Solr as Index for queries and retrieving data from normal App-Schema datasource (SQL DB, MongoDB, ... ). The only requirement to use it is having Geoserver App-Schema extension and Solr extension installed. How Index layer works ^^^^^^^^^^^^^^^^^^^^^ When App-Schema detects the index layer is activated for a FeatureType, it will use Solr configured fields for every query incoming from Geoserver OWS requests. If the incoming query uses only indexed fields App-Schema will query only on Solr data source for retrieving matching features IDs and will connect to normal data source to get all in depth data but exclusively for matching IDs. .. warning:: note that both Primary Keys (solr index core and data source) should match to get Index layer working. Linking an index only store ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Begin creating the SolrDataStore definition as usual along with the Postgis store definition: .. code-block:: xml (...) (...) stations_index http://localhost:8983/solr/stations location 4326 POINT postgis_dataStore Connection timeout 20 port 5432 passwd postgres dbtype postgis (...) Link a solr index as index layer on FeatureTypeMapping setting: * indexDataStore : The SolrDataStore id property from the store you use as index layer only. * indexType : The solr core to use. .. code-block:: xml (...) Stations postgis_dataStore meteo_stations st:Station st:position stations_index stations (...) Linking an index enabled attribute ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ To link a solr core field as index for an AttributeMapping you only need to add an indexField definition with this format: .. code-block:: xml (...) ${SOLR_FIELD_NAME} (...) * ${SOLR_FIELD_NAME} : The field name from solr core to use in index layer. For example if you need to use solr fields: station_id and station_name; you will write on mapping: .. code-block:: xml st:Station id station_id st:stationName strConcat('1_', common_name) station_name