diff --git a/pygeoapi/provider/elasticsearch_.py b/pygeoapi/provider/elasticsearch_.py index 39b795dee..ff016901e 100644 --- a/pygeoapi/provider/elasticsearch_.py +++ b/pygeoapi/provider/elasticsearch_.py @@ -513,9 +513,9 @@ def get_properties(self): if not self.properties and not self.select_properties: all_properties = self.get_fields() if self.properties and self.select_properties: - all_properties = set(self.properties) & set(self.select_properties) + all_properties = self.properties and self.select_properties else: - all_properties = set(self.properties) | set(self.select_properties) + all_properties = self.properties or self.select_properties LOGGER.debug(f'resulting properties: {all_properties}') return all_properties diff --git a/tests/test_elasticsearch__provider.py b/tests/test_elasticsearch__provider.py index 715936bf0..0b64efb48 100644 --- a/tests/test_elasticsearch__provider.py +++ b/tests/test_elasticsearch__provider.py @@ -45,6 +45,20 @@ def config(): } +@pytest.fixture() +def config_ordered_properties(): + return { + 'name': 'Elasticsearch', + 'type': 'feature', + 'data': 'http://localhost:9200/ne_110m_populated_places_simple', # noqa + 'id_field': 'geonameid', + 'properties': [ + 'adm0name', + 'adm1name' + ] + } + + @pytest.fixture() def config_cql(): return { @@ -211,6 +225,15 @@ def test_query(config): assert len(results['features'][0]['properties']) == 1 +def test_query_ordered_properties(config_ordered_properties): + p = ElasticsearchProvider(config_ordered_properties) + + result = p.query() + feature_properties = list(result['features'][0]['properties'].keys()) + + assert feature_properties == ['adm0name', 'adm1name'] + + def test_get(config): p = ElasticsearchProvider(config)