opengeospatial / ogcapi-features

An open standard for querying geospatial information on the web.
https://ogcapi.ogc.org/features
Other
342 stars 85 forks source link

Use of /queryables for filtering on feature properties without "filter" query parameter #778

Closed ycespb closed 1 year ago

ycespb commented 1 year ago

The notion of queryables and the /queryables response is currently tied to the "filtering" extension and the "filter" HTTP query parameter. However, the PGC API-Features Core (Part 1) already mentions http://docs.opengeospatial.org/is/17-069r3/17-069r3.html#_parameters_for_filtering_on_feature_properties which to be implemented without inspecting the OpenAPI definition requires also a list of "queryables" to which this filtering_on_feature_properties applies. Could there not be a separate conformance class that supports the above filtering through advertising queryables via /collections/id/queryables without requiring support for the "filter" keyword. This would allow for supporting queries such as 'function=public+use' (example from http://docs.opengeospatial.org/is/17-069r3/17-069r3.html#_parameters_for_filtering_on_feature_properties where "function" is an HTTP query parameter.

The existence of such simpler mechanism exploiting "queryables" without "filter" HTTP query parameter seems to be assumed by the draft OGC API-Records standard at https://docs.ogc.org/DRAFTS/20-004.html#_overview_4.

cportele commented 1 year ago

This is how we have implemented it in ldproxy - the queryables of an API with Feature resources are also mapped to query parameters as specified in Part 1.

However, in Part 1 the requirements are intentionally kept to a minimum. The query parameters are documented in the API definition, but there is no requirement to "duplicate" this information in an additional resource.

The Queryables resource is added in Part 3, because for APIs implementing richer filtering support the additional overhead to implement another resource seems acceptable and the information cannot be documented properly in the API definition anyhow.

I don't think that the Queryables resource belongs into Part 1 for those reasons. What could be an option is to make the Queryables resource a separate conformance class in Part 3 (with the implication that if Features Part 1 is supported, queryables that are feature properties must also be implemented as query parameters). The Filter conformance class would then depend on the Queryables conformance class.

But is "worth" an additional conformance class? I think most implementations implementing Queryables will also support Filtering and implementations of Part 1 are also free to support the Queryables resource in the API without support for Filtering - the Queryables would be discoverable from the Collection resource or the API definition, just not the Conformance Declaration.

aaime commented 1 year ago

I guess a possible attraction of this combination would be to avoid declaring the queryables in the API document to start with, in order to support implementations with many (thousands or more) collections without having to generate an impractically large API definition.

m-mohr commented 1 year ago

Is there a conformance class that tells a client what a server supports? For CQL (filter=...) there's a conformance class and queryables apply, but how can a client detect whether the ?prop=... notion is supported and whether queryables apply there or not?

ycespb commented 1 year ago

Indeed, there should be a way (e.g. a dedicated conformance class in Part 3 from which the "filter" conformance class then for instance depends) to support "queryables" (and/queryables for each individual "collection") (as current EO/CEOS OpenSearch interfaces do) without having to implement a full query language (like CQL). Otherwise, this would be an obstacle to migrate implementations from their OpenSearch API (already returning GeoJSON) to OGC API - Feature / Records / STAC implementations.

cportele commented 1 year ago

Meeting 2023-02-15:

@cportele will create the PR.

ycespb commented 1 year ago

@cportele, the new conformance class is a very elegant solution and allows for filtering without the full-fledged filter and CQL complexity. It would be nice if strict interpretation of this would allow a server to advertise via the /collections/{collectionId}/queryables response the following information to clients using the normal JSON Schema encoding:

This could allow encoding in JSON(-Schema) Queryables what in the past was encoded in an XML-based (collection-specific) OpenSearch OSDD document with Parameter extensions (without the need for the client to parse collection-specific OpenAPI documents).

m-mohr commented 1 year ago
  • whether a search parameter is mandatory or optional in a search request via "required": ["datetime"] (some backends may require the presence of datetime for instance or a STAC API implementation may require the collections queryable to be present) "required": ["collections"].

@ycespb If this is set to required, can I still make a simple request to /items without any parameters or would datetime always be required? The latter seems like a bad idea as it would break clients that don't support queryables.

ycespb commented 1 year ago

@m-mohr This is a valid point, However, it you look at it from the server implementation side (in some cases a proxy in front of (multiple) legacy systems), in some cases such "open" requests are not possible or not allowed (if result sets become too large due to lack of precision of the request, typically no time or geographical constraint present). In some systems, the "indexes" are optimised per "collection" and open-requests not specifying the collection is not possible or very inefficient/slow. I would expect however that a request to /items without any parameters is easier to handle server-side than a request to /search without any parameters (collections in particular). The combination of the "Queryables" conformance class (or the "Filter" conformance class) with the STAC "/search" endpoint is not so easy in my opinion. As the "/search" is in principle cross-collection, clients would have to use the intersection of the Queryables response of all concerned collections to see what queryables are allowed at that endpoint (with which restrictions - min/max/enums) unless exactly one collection is identified in the collections queryable. The same issue exists for the use of filter in combination with /collections/collection-id/queryables responses.

m-mohr commented 1 year ago

I'm just talking about /items - /items without query parameters should always return a result (can be paginated and as such be limited to x random items), otherwise, many clients won't be able to handle the API.

cportele commented 1 year ago

@ycespb - Thank you for the comments. My thoughts:

m-mohr commented 1 year ago
  • If a server decides that it will not execute the request it should return a 403 response:

@cportele Shouldn't that be a 400? 403 (and 401) are primarily meant for authorization: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403

cportele commented 1 year ago

@m-mohr I don't think so. The text in the deprecated RFC 7231 was actually kind of implying this, but "refuses to authorize it" was changed in RFC 9110 to "refuses to fulfill it" (as it was in RFC 2616). 403 is commonly used to indicate insufficient permissions, but it is not restricted to this.

There was a discussion in the IETF HTTP WG about this topic.