Skip to content

Commit e1fec87

Browse files
authored
add support for OpenSearch provider (geopython#1844)
1 parent 065ef3a commit e1fec87

File tree

9 files changed

+1216
-4
lines changed

9 files changed

+1216
-4
lines changed

.github/workflows/main.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ jobs:
6262
host node port: 9300
6363
node port: 9300
6464
discovery type: 'single-node'
65+
- name: Install and run OpenSearch 📦
66+
uses: esmarkowski/[email protected]
67+
with:
68+
version: 2.12.0
69+
security-disabled: true
70+
port: 9209
6571
- name: Install and run MongoDB
6672
uses: supercharge/[email protected]
6773
with:
@@ -99,6 +105,7 @@ jobs:
99105
- name: setup test data ⚙️
100106
run: |
101107
python3 tests/load_es_data.py tests/data/ne_110m_populated_places_simple.geojson geonameid
108+
python3 tests/load_opensearch_data.py tests/data/ne_110m_populated_places_simple.geojson geonameid
102109
python3 tests/load_mongo_data.py tests/data/ne_110m_populated_places_simple.geojson
103110
gunzip < tests/data/hotosm_bdi_waterways.sql.gz | psql postgresql://postgres:${{ secrets.DatabasePassword || 'postgres' }}@localhost:5432/test
104111
psql postgresql://postgres:${{ secrets.DatabasePassword || 'postgres' }}@localhost:5432/test -f tests/data/dummy_data.sql
@@ -117,6 +124,7 @@ jobs:
117124
pytest tests/test_csv__provider.py
118125
pytest tests/test_django.py
119126
pytest tests/test_elasticsearch__provider.py
127+
pytest tests/test_opensearch__provider.py
120128
pytest tests/test_esri_provider.py
121129
pytest tests/test_filesystem_provider.py
122130
pytest tests/test_geojson_provider.py

docs/source/data-publishing/ogcapi-features.rst

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ parameters.
2626
`GeoJSON`_,✅/✅,results/hits,❌,❌,❌,✅,❌,❌,✅
2727
`MongoDB`_,✅/❌,results,✅,✅,✅,✅,❌,❌,✅
2828
`OGR`_,✅/❌,results/hits,✅,❌,❌,✅,❌,❌,✅
29+
`OpenSearch`_,✅/✅,results/hits,✅,✅,✅,✅,✅,✅,✅
2930
`Oracle`_,✅/✅,results/hits,✅,❌,✅,✅,❌,❌,✅
3031
`Parquet`_,✅/✅,results/hits,✅,✅,❌,✅,❌,❌,✅
3132
`PostgreSQL`_,✅/✅,results/hits,✅,✅,✅,✅,✅,❌,✅
@@ -322,6 +323,44 @@ The OGR provider requires a recent (3+) version of GDAL to be installed.
322323
The `crs` query parameter is used as follows:
323324
e.g. ``http://localhost:5000/collections/foo/items?crs=http%3A%2F%2Fwww.opengis.net%2Fdef%2Fcrs%2FEPSG%2F0%2F28992``.
324325

326+
.. _OpenSearch:
327+
328+
OpenSearch
329+
^^^^^^^^^^
330+
331+
.. note::
332+
Requires Python package opensearch-py
333+
334+
To publish an OpenSearch index, the following are required in your index:
335+
336+
* indexes must be documents of valid GeoJSON Features
337+
* index mappings must define the GeoJSON ``geometry`` as a ``geo_shape``
338+
339+
.. code-block:: yaml
340+
341+
providers:
342+
- type: feature
343+
name: OpenSearch
344+
editable: true|false # optional, default is false
345+
data: http://localhost:9200/ne_110m_populated_places_simple
346+
id_field: geonameid
347+
time_field: datetimefield
348+
349+
.. note::
350+
351+
For OpenSearch indexes that are password protect, a RFC1738 URL can be used as follows:
352+
353+
``data: http://username:password@localhost:9200/ne_110m_populated_places_simple``
354+
355+
To further conceal authentication credentials, environment variables can be used:
356+
357+
``data: http://${MY_USERNAME}:${MY_PASSWORD}@localhost:9200/ne_110m_populated_places_simple``
358+
359+
The OpenSearch provider also has the support for the CQL queries as indicated in the table above.
360+
361+
.. seealso::
362+
:ref:`cql` for more details on how to use Common Query Language (CQL) to filter the collection with specific queries.
363+
325364
.. _Oracle:
326365

327366
Oracle

pygeoapi/api/itemtypes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ def post_collection_items(
889889
HTTPStatus.BAD_REQUEST, headers, request.format,
890890
'InvalidParameterValue', msg)
891891
else:
892-
LOGGER.debug('processing Elasticsearch CQL_JSON data')
892+
LOGGER.debug('processing CQL_JSON data')
893893
try:
894894
filter_ = CQLModel.parse_raw(data)
895895
except Exception:

pygeoapi/plugin.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,11 @@
5151
'MapScript': 'pygeoapi.provider.mapscript_.MapScriptProvider',
5252
'MongoDB': 'pygeoapi.provider.mongo.MongoProvider',
5353
'MVT-tippecanoe': 'pygeoapi.provider.mvt_tippecanoe.MVTTippecanoeProvider', # noqa: E501
54-
'MVT-elastic': 'pygeoapi.provider.mvt_elastic.MVTElasticProvider', # noqa: E501
55-
'MVT-proxy': 'pygeoapi.provider.mvt_proxy.MVTProxyProvider', # noqa: E501
54+
'MVT-elastic': 'pygeoapi.provider.mvt_elastic.MVTElasticProvider',
55+
'MVT-proxy': 'pygeoapi.provider.mvt_proxy.MVTProxyProvider',
5656
'OracleDB': 'pygeoapi.provider.oracle.OracleProvider',
5757
'OGR': 'pygeoapi.provider.ogr.OGRProvider',
58+
'OpenSearch': 'pygeoapi.provider.opensearch_.OpenSearchProvider',
5859
'Parquet': 'pygeoapi.provider.parquet.ParquetProvider',
5960
'PostgreSQL': 'pygeoapi.provider.postgresql.PostgreSQLProvider',
6061
'rasterio': 'pygeoapi.provider.rasterio_.RasterioProvider',

0 commit comments

Comments
 (0)