Skip to content

add support for feature/record domain queries #1988

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 2, 2025
Merged

Conversation

tomkralidis
Copy link
Member

@tomkralidis tomkralidis commented Mar 30, 2025

Overview

This PR adds support for OGC API - Features and OGC API - Records domains within /collections/{collectionId}/queryables), as per OGC API - Features - Part 5: Schemas, and as discussed during last week's OGC Standards Code Sprint. The feature is driven by the OGC API - Records SWG discussion, but also applies to OGC API - Features.

Related Issue / discussion

Additional information

See discussion in OGC API - Records / OGC API - Features SWGs:

Note that functionality may be updated in the future.

Dependency policy (RFC2)

  • I have ensured that this PR meets RFC2 requirements

Updates to public demo

Contributions and licensing

(as per https://github.com/geopython/pygeoapi/blob/master/CONTRIBUTING.md#contributions-and-licensing)

  • I'd like to contribute [feature X|bugfix Y|docs|something else] to pygeoapi. I confirm that my contributions to pygeoapi will be compatible with the pygeoapi license guidelines at the time of contribution
  • I have already previously agreed to the pygeoapi Contributions and Licensing Guidelines

@tomkralidis tomkralidis added enhancement New feature or request OGC API - Records OGC API - Records labels Mar 30, 2025
@tomkralidis tomkralidis added this to the 0.21.0 milestone Mar 30, 2025
@pvgenuchten
Copy link
Contributor

do you have a link to that discussion, from the code i understand the domains method returns the unique domain values for each of the properties of records in the records collection.

  • Does it make sense for fields like title/abstract?
  • How does this functionality compare to the facets extension, which returns the same information for the current search (and including count)

@tomkralidis tomkralidis changed the title add support for OGC API - Records domains [WIP] add support for OGC API - Records domains Mar 31, 2025
@tomkralidis tomkralidis added the OGC API - Features OGC API - Features label Mar 31, 2025
@tomkralidis tomkralidis changed the title [WIP] add support for OGC API - Records domains add support for domain queries Mar 31, 2025
@tomkralidis tomkralidis changed the title add support for domain queries add support for feature/record domain queries Mar 31, 2025
@tomkralidis
Copy link
Member Author

do you have a link to that discussion, from the code i understand the domains method returns the unique domain values for each of the properties of records in the records collection.

There will be an issue in OGC API - Records shortly, and I will link it here.

Note that this PR, given updated discussion, now provides this functionality in .../querables (and not .../domains), and applies to BOTH OGC API - Records and OGC API - Features (though OGC API - Records is a more direct use case IMO, we still get it "for free" given OGC API - Features - Part 5, where this work is targeted).

* Does it make sense for fields like title/abstract?

In theory it shouldn't matter. From a pygeoapi perspective, the default providers with this support are simply operating on the underlying data. A custom provider plugin can exercise more control as required.

* How does this functionality compare to the facets extension, which returns the same information for the current search (and including count)

OGC API - Records - Part 2: Facets is more about aggregations/computes based on search results, vs. describing a collection's queryables/live enums.

@@ -370,6 +370,24 @@ def get_fields(self):

return fields

def get_domains(self, properties=[], urrent=False) -> tuple:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

current?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixed.

Copy link
Contributor

@doublebyte1 doublebyte1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this really cutting edge feature! 👍🏽

  • I am not sure where this is documented, but if there is a place maybe it is worth leaving a link to it in the pygeoapi docs.
  • This is kind of a low level thing, being very implementation specific. I realised the success of this functionality is also deployment specific; in the case of elasticsearch, it will fail to get the domains if the mappings are not done in a certain way. But I guess this is a best effort from the server.


for key, value in response['aggregations'].items():
if self.fields[key]['type'] in ['string', 'number']:
values = [x['key'] for x in value['buckets']]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that elastic fails to do the aggregation of strings, when fields are not mapped as raw, but I guess this is too specific of the index, not much we can do. Something to keep in mind, though.

This fails:

            "namealt": {
              "type": "text",
              "fields": {
                "keyword": {
                  "type": "keyword",
                  "ignore_above": 256
                }
              }
            },

this works:

            "nameascii": {
              "type": "text",
              "fields": {
                "raw": {
                  "type": "keyword"
                }
              } 

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

es-mappings

@tomkralidis
Copy link
Member Author

do you have a link to that discussion, from the code i understand the domains method returns the unique domain values for each of the properties of records in the records collection.

There will be an issue in OGC API - Records shortly, and I will link it here.

FYI the associated GitHub issues can now be found per below:

@tomkralidis tomkralidis merged commit bfeb0c3 into master Apr 2, 2025
7 checks passed
@tomkralidis tomkralidis deleted the oarec-domains branch April 2, 2025 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request OGC API - Features OGC API - Features OGC API - Records OGC API - Records
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants