My observations and recommendation:
id
appears to be interpreted as an internal keyword for FeatureID and not a property/attribute/column name. Many datasets will use id
as a column name and might get tripped up by this.
Example, using the topp:states layer in the default data:
http://localhost:8080/geoserver/ows?service=WFS&version=1.0.0&request=GetFeature&typeNames=topp:states&outputFormat=json
Here, id
is the FeatureID = states.49
and thus http://localhost:8080/geoserver/ows?service=WFS&version=1.0.0&request=GetFeature&typeNames=topp:states&outputFormat=json&cql_filter=id+IN+('states.49’) will return this one result.
However, if we customise the attributes and change attribute STATE_NAME
to id
, simulating a non-index database column called id
:
then http://localhost:8080/geoserver/ows?service=WFS&version=1.0.0&request=GetFeature&typeNames=topp:states&outputFormat=json&cql_filter=id+IN+('Washington’) will not match the record, as id
is being used as the FeatureID. In order to use the column id
, we need to put it in double quotes:
http://localhost:8080/geoserver/ows?service=WFS&version=1.0.0&request=GetFeature&typeNames=topp:states&outputFormat=json&cql_filter=“id”+IN+(‘Washington’), and this then works, as per the https://gis.stackexchange.com/questions/373005/geoserver-wms-cql-filter-id-xxx-works-but-id-in-xxx-does-not recommendation.
Simply using the IN(filter) format: http://localhost:8080/geoserver/ows?service=WFS&version=1.0.0&request=GetFeature&typeNames=topp:states&outputFormat=json&cql_filter=IN+(‘Washington’), implies the FeatureID id
and does not return any data.
The XML equivalent: http://localhost:8080/geoserver/wfs?request=GetFeature&version=1.0.0&typeName=topp:states&outputFormat=json&FILTER=%3CFilter%20xmlns%3D%22http%3A%2F%2Fwww.opengis.net%2Fogc%22%3E%3CPropertyIsEqualTo%3E%3CPropertyName%3Eid%3C%2FPropertyName%3E%3CLiteral%3EWashington%3C%2FLiteral%3E%3C%2FPropertyIsEqualTo%3E%3C%2FFilter%3E (which encodes this filter, for those of us who can’t easily URL-decode in our heads:
id
Washington
)
does correctly use the attribute id
, as expected, and not the FeatureID id
.
According to the both https://docs.geoserver.org/latest/en/user/filter/ecql_reference.html and https://docs.geoserver.org/latest/en/user/tutorials/cql/cql_tutorial.html,
and
it appears as though we should be able to filter on attribute id
= Washington rather than FeatureID id
= states.49
If this is a bug (developers?), I wonder how many systems will break when it is fixed, or whether the best way forward is to simply document that an attribute id
is special and needs to be quoted thus: “id”. Let me know to fix the documentation.
Peter
GeoServer PSC
AWS Solutions Architect
https://github.com/petersmythe
On Sat, 10 Feb 2024 at 21:35, Jody Garnett <jody.garnett@…84…> wrote:
Huh, I wonder if that is even supported …
The FeatureID check is done different by WFS, and does not always integrate well with functions and so on. There is a configuration option to both use primary keys to generate FeatureID and also make available as an attribute for use with functions.
Are you comfortable trying the same request with an XML query? …to see if it is a problem with the data store, or if it is a problem with CQL constructing a query …
Reading
https://docs.geoserver.org/main/en/user/filter/ecql_reference.html you may wish to try:
in(‘R403139’)
Assuming R403139 is a feature identifier.
–
Jody Garnett
On Sat, Feb 10, 2024 at 6:16 AM <wambacher@…9782…> wrote:
Hi,
i’m trying to use a cql_filter on a feature but something is strange.
cql_filter: “id = ‘R403139’” is working fine. i’ll get only this feature.
but “id in(‘R403139’)” does not give any result (without error messages).
i need a list, because later on there more features will be dynanical selected. e.g. “id in(‘R403139’, ‘R1719140’)”
What am i doing wrong?
btw: i may add geoserver log file if needed.
–
My projects:
OSM Boundaries Map () - not completed
OSM Software Watchlist
OSM Emergency Map ()
OSM Healthcare Map (*)
OSM Postcode Map (Germany)
*) Europe
Geoserver-users mailing list
Please make sure you read the following two resources before posting to this list:
If you want to request a feature or an improvement, also see this: https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users
Geoserver-users mailing list
Please make sure you read the following two resources before posting to this list:
If you want to request a feature or an improvement, also see this: https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users
Geoserver-devel mailing list
Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel