configuration.rst 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. .. _opensearch_eo_configuration:
  2. Configuring the OpenSearch module
  3. =================================
  4. The OpenSearch module needs to know upon which database perform the searches.
  5. Follow these steps:
  6. * Setup a standard PostGIS database pointing to the database and schema created above
  7. from the SQL file. Note down the full name of the store (e.g. ``test:metadata`` where ``test``
  8. is the workspace and ``metadata`` is the store name).
  9. Besides filling the connection parameters, remember to set "expose primary keys" to true.
  10. * Create a new store of type "JDBC based OpenSearch store" and configure the fully qualified name
  11. of the basic PostGIS store in its "store" parameter.
  12. .. figure:: images/store.png
  13. :align: center
  14. * Go into the "OS-EO" service configuration page and configure the "OpenSearch" store
  15. * (Optional) You can also configure how long values will be cached for performance purposes for templates that require collection level aggregate statistics by adjusting the cache time to live duration and time units.
  16. .. figure:: images/service.png
  17. * Global Queryables (applicable to the STAC API to define queryable fields for all Collections) can be configured
  18. using a comma delimited list in the text box under OpenSearch specific metadata
  19. .. figure:: images/queryables.png
  20. Advanced: adding product classes
  21. --------------------------------
  22. The design of the OpenSearch module is "data driven", meaning that one can materialize new
  23. search properties by just adding new columns to the product and collection tables.
  24. In particular, both tables have a "prefix based" convention linking the properties to their
  25. respective product types, and the engine will advertise for a particular product only
  26. the properties relevant to it. For example, in an optical product, the properties starting
  27. with "opt" will be listed, but not those starting with "sar".
  28. Here is a table of the product classes known out of the box:
  29. .. list-table::
  30. :widths: 10 10 20 60
  31. :header-rows: 1
  32. * - Name
  33. - Prefix
  34. - Namespace
  35. - Description
  36. * - eop_generic
  37. - eop
  38. - http://www.opengis.net/eop/2.1
  39. - Base properties shared among all EO products. Never remove this class.
  40. * - optical
  41. - opt
  42. - http://www.opengis.net/opt/2.1
  43. - Optical products properties
  44. * - radar
  45. - sar
  46. - http://www.opengis.net/sar/2.1
  47. - Radar products properties
  48. * - Altimetric
  49. - alt
  50. - http://www.opengis.net/alt/2.1
  51. - Altimetric products properties
  52. * - Atmospheric
  53. - atm
  54. - http://www.opengis.net/atm/2.1
  55. - Atmospheric products properties
  56. * - Limb
  57. - lmb
  58. - http://www.opengis.net/lmb/2.1
  59. - Limb products properties
  60. * - ssp
  61. - ssp
  62. - http://www.opengis.net/ssp/2.1
  63. - SSP products properties
  64. The various properties have different usages:
  65. * The *name* is used in the collection to define the type of sensor (eoSensorType column)
  66. * The *prefix* is used in the product table as a prefix to column name in order to associate
  67. them to a particular product type, shows up as-is in the JSON representations of the REST API,
  68. as well as the prefix in XML outputs
  69. * The *namespace* is used in XML output, along with the prefix (e.g., ``xmlns:opt="http://www.opengis.net/opt/2.1"``)
  70. It is possible to add new product classes as well as changing the built-in ones, but care should
  71. be taken to keep product classes and database aligned. After any change to the database structure
  72. remember to "reset" the GeoServer configuration to make it re-scan the table structures.
  73. .. _oseo_html_templates:
  74. HTML templates
  75. --------------
  76. The Freemarker templates for collections and products can be found in ``$GEOSERVER_DATA_DIRECTORY/templates/os-eo``:
  77. * `generic-header.ftl <https://github.com/geoserver/geoserver/blob/main/src/community/oseo/oseo-service/src/main/resources/org/geoserver/opensearch/eo/response/>`_ receives SearchResults, Query, organization, title, updated(date), builder and encodes a generic header Atom HTML description for it.
  78. * `generic-footer.ftl <https://github.com/geoserver/geoserver/blob/main/src/community/oseo/oseo-service/src/main/resources/org/geoserver/opensearch/eo/response/>`_ exists simple for having a </feed> closing tag.
  79. * `product.ftl <https://github.com/geoserver/geoserver/blob/main/src/community/oseo/oseo-service/src/main/resources/org/geoserver/opensearch/eo/response/product.ftl>`_ receives an OpenSearch product, updated(date), dcDate(date), offerings and encodes the Atom HTML description for it.
  80. * `collection.ftl <https://github.com/geoserver/geoserver/blob/main/src/community/oseo/oseo-service/src/main/resources/org/geoserver/opensearch/eo/response/collection.ftl>`_ receives an OpenSearch collection, updated(date), dcDate(date), offerings and encodes the Atom HTML description for it.
  81. The default templates, linked above, report the time range for the product/collection, and link
  82. to other pertinent OpenSearch resources (metadata, self link, quicklooks).
  83. Collection specific templates can be set up in the data directory, appending the collection
  84. identifier to the file name, e.g. ``collection-SENTINEL2.ftl`` or ``product-SENTINEL2.ftl``.
  85. The templates can use a ``oseoLink`` function to build links pointing back to the OpenSearch service.
  86. The function receives the following parameters:
  87. * The first argument is a ``path`` segment under the ``oseo`` service path.
  88. * The other arguments, optional, are couple of keys and values, used to encode the link's query string.
  89. .. _oseo_metadata_templates:
  90. Metadata templates
  91. ------------------
  92. The Freemarker metadata templates for collections and products can be found in ``$GEOSERVER_DATA_DIRECTORY/templates/os-eo``:
  93. * `product-metadata.ftl <https://github.com/geoserver/geoserver/blob/main/src/community/oseo/oseo-service/src/main/resources/org/geoserver/opensearch/eo/response/product-metadata.ftl>`_ receives an OpenSearch product and encodes the Atom HTML description for it.
  94. * `collection-metadata.ftl <https://github.com/geoserver/geoserver/blob/main/src/community/oseo/oseo-service/src/main/resources/org/geoserver/opensearch/eo/response/collection-metadata.ftl>`_ receives an OpenSearch collection and encodes the Atom HTML description for it.
  95. The default templates, linked above, generate respectively a ISO metadata sheet for collections, and a
  96. EO O&M product metadata sheet for products.
  97. The templates can use a ``oseoLink`` function to build links pointing back to the OpenSearch service.
  98. The function receives the following parameters:
  99. * The first argument is a ``path`` segment under the ``oseo`` service path.
  100. * The other arguments, optional, are couple of keys and values, used to encode the link's query string.
  101. The templates can also use a ``gml`` function that generates a GML 3.2 representation of a
  102. geometry (mind, the output must be forced not to be escaped, using ``?no_esc``, as well
  103. as ``minx``, ``miny``, ``maxx``, ``maxy`` that can be used to extract the bounding box
  104. corner values. All these function expect a geometry as input.
  105. Finally templates can use a ``loadJSON`` function to read a JSON from a file inside the GeoServer data directory.
  106. The path to the JSON file can be absolute eg. :code:`"${loadJSON('/path/to/read.json')}"`, or a plain file name, in case the JSON file is present in the GeoServer root directory eg. :code:`"${loadJSON('read.json')}"`.
  107. The function returns a string JSON that can be parsed using the :code:`?eval_json` free marker built-in function:
  108. :code:`<#assign loadedJSON = "${loadJSON('readAndEval.json')}">`
  109. :code:`<#assign evalJSON = loadedJSON?eval_json>`
  110. More information about writing templates can be found in the :ref:`templates guide <oseotemplates>`.
  111. GeoJSON output templates
  112. ------------------------
  113. The module supports GeoJSON encoding of collections and products according to the
  114. <OGC OpenSearch-EO GeoJSON(-LD) Response Encoding Standard`https://docs.opengeospatial.org/is/17-047r1/17-047r1.html`>_.
  115. Give the structure required in output, it's not possible to use the simple features GeoJSON encoders.
  116. The module is instead using two dedicated :ref:`features templates <community_wfstemplating>`,
  117. that the user can customize to match the database structure.
  118. The default templates are part of the GeoServer distribution, and are automatically copied to the
  119. data directory on startup, to allow for customization:
  120. * `$GEOSERVER_DATA_DIR/templates/os-eo/products.json` is the `products template <https://raw.githubusercontent.com/geoserver/geoserver/main/src/community/oseo/oseo-service/src/main/resources/org/geoserver/opensearch/eo/products.json>`_
  121. * `$GEOSERVER_DATA_DIR/templates/os-eo/collections.json` is the `collections template <https://raw.githubusercontent.com/geoserver/geoserver/main/src/community/oseo/oseo-service/src/main/resources/org/geoserver/opensearch/eo/collections.json>`_
  122. The default templates work against the `default PostGIS database structure <https://raw.githubusercontent.com/geoserver/geoserver/main/src/community/oseo/oseo-core/src/test/resources/postgis.sql>`_ and
  123. can be customized to include new properties to follow eventual database modifications.
  124. Collection specific templates can also be provided, which would contain directives and mappings unique to that collection.
  125. A collection specific template can be placed in the same templates directory as above, called
  126. either ``collections-<COLLECTION_ID>.json`` or ``products-<COLLECTION_ID>.json``
  127. where ``<COLLECTION_ID>`` is the collection identifier.
  128. For example, if the collection is named ``SENTINEL2`` a products template specific for it will
  129. be named ``products-SENTINEL2.json``, while the collection template will be named ``collections-SENTINEL2.json``.
  130. More information about writing templates can be found in the :ref:`templates guide <oseotemplates>`.