configure.rst 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. .. _community_solr_configure:
  2. SOLR layer configuration
  3. ========================
  4. Mapping documents to layers
  5. ---------------------------
  6. SOLR indexes almost free form documents, the SOLR instance has a collection of fields, and
  7. each document can contain any field, in any combination.
  8. On the other side, GeoServer organizes data in fixed structure feature types, and exposes
  9. data in separate layers. This leaves the question of how documents in the index
  10. should be organized into layers.
  11. By default the store exposes a single layer, normally named after the SOLR collection the store is connected
  12. to, by publishing it one can decide which fields to include, and eventually add a filter
  13. to select which attributes it will contain.
  14. This single layer can be published multiple times, giving each published layer a different name,
  15. set of selected attributes, and a different filter to select the documents contained in the layer.
  16. Installing the SOLR extension
  17. -----------------------------------
  18. #. Download the SOLR extension from the `nightly GeoServer community module builds <https://build.geoserver.org/geoserver/main/community-latest/>`_.
  19. .. warning:: Make sure to match the version of the extension to the version of the GeoServer instance.
  20. #. If GeoServer is running, stop it.
  21. #. Extract the contents of the archive into the ``WEB-INF/lib`` directory of the GeoServer installation.
  22. #. Restart GeoServer, the SOLR data store should show up as an option when going through the new store
  23. creation workflow.
  24. Connecting to a SOLR server
  25. ----------------------------
  26. Once the extension is properly installed ``SOLR`` will show up as an option when creating a new data store.
  27. .. figure:: images/solr_store.png
  28. :align: center
  29. *SOLR in the list of vector data sources*
  30. .. _community_solr_configure_store:
  31. Configuring a SOLR data store
  32. -----------------------------
  33. .. figure:: images/solr_configuration.png
  34. :align: center
  35. *Configuring a SOLR data store*
  36. .. list-table::
  37. :widths: 20 80
  38. * - ``solr_url``
  39. - Provide a link to the SOLR server that provides the documents
  40. Once the parameters are entered and confirmed, GeoServer will contact the SOLR server and
  41. fetch a list of layer names and fill the layer chooser page accordingly:
  42. .. figure:: images/solr_layerlist.png
  43. :align: center
  44. *List of layers available in the SOLR server*
  45. Configuring a new SOLR base layer
  46. ---------------------------------
  47. Once the layer name is chosen, the usual layer configuration panel will appear, with a pop-up showing
  48. in a table the fields available:
  49. .. figure:: images/solr_fieldlist.png
  50. :align: center
  51. *The layer field list configuration*
  52. .. list-table::
  53. :widths: 20 80
  54. * - ``Is empty``
  55. - Read only fields, checked if the field has no values in the documents associated to this layer
  56. * - ``Use``
  57. - Used to select the fields that will make up this layer features
  58. * - ``Name``
  59. - Name of the field
  60. * - ``Type``
  61. - Type of the field, as derived from the SOLR schema. For geometry types, you have the option to provide a more specific data type
  62. * - ``SRID``
  63. - Native spatial reference ID of the geometries
  64. * - ``Default geometry``
  65. - Indicates if the geometry field is the default one. Useful if the documents contain more than one geometry field,
  66. as SLDs and spatial filters will hit the default geometry field unless otherwise specified
  67. * - ``Identifier``
  68. - Check if the field can be used as the feature identifier
  69. By default the list will contain only the fields that have at least one non null value in the documents
  70. associated to the layer, but it is possible to get the full list by un-checking the "Hide field if empty"
  71. check-box:
  72. .. figure:: images/solr_fieldlist_all.png
  73. :align: center
  74. *Showing all fields available in SOLR*
  75. Once the table is filled with the all the required parameters, press the "Apply" button to confirm
  76. and go back to the main layer configuration panel.
  77. Should the choice of fields be modified, you can click the "Configure SOLR fields" just below the "Feature Type Details" panel.
  78. .. figure:: images/solr_fieldlist_edit.png
  79. :align: center
  80. *Going back to the field list editor*
  81. The rest of the layer configuration works as normal, once all the fields are provided you'll be able to
  82. save and use the layer in WMS and WFS.
  83. .. warning:: In order to compute the bounding box GeoServer will have to fetch all the geometries making up the layer out of SOLR,
  84. this operation might take some time, you're advised to manually entered the native bounding box when configuring a
  85. layer out of a large document set
  86. Custom ``q`` and ``fq`` parameters
  87. ----------------------------------
  88. The SOLR store will translate most OGC filters, as specified in SLD, CQL Filter or OGC filter,
  89. down into the SOLR engine for native filtering, using the ``fq`` parameter.
  90. However, in some occasions you might need to specify manually either ``q`` or ``fq``, to leverage
  91. some native SOLR filtering ability that cannot be expressed via OGC filters.
  92. This can be done by specifying those as ``viewparams``, pretty much like in parametric sql views
  93. atop relational databases.
  94. For example, the following URL::
  95. http://localhost:8080/geoserver/nurc/wms?service=WMS&version=1.1.0&request=GetMap
  96. &layers=nurc:active&styles=geo2&bbox=0.0,0.0,24.0,44.0&width=279&height=512
  97. &srs=EPSG:4326&format=application/openlayers
  98. &viewparams=fq:security_ss:WEP
  99. Will send down to SOLR a query looking like::
  100. omitHeader=true&fl=geo,id&q=*:*&rows=2147483647&sort=id asc
  101. &fq=status_s:active AND geo:"Intersects(POLYGON ((-0.125 -0.5333333333333333, -0.125 44.53333333333333,
  102. 24.125 44.53333333333333, 24.125 -0.5333333333333333, -0.125 -0.5333333333333333)))"
  103. &fq=security_ss:WEP&cursorMark=*
  104. You can notice that:
  105. * Only the columns needed for the display (in this case, a single geometry) are retrieved
  106. * The bbox and layer identification filters are specified in the first ``fq``
  107. * The custom ``fq`` is passed as a second ``fq`` parameter (SOLR will treat it as being and-ed with
  108. the previous one)