[Geoserver-users] trouble with cql_filter

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

Hi Wambacher

You might be running into this issue: https://gis.stackexchange.com/questions/373005/geoserver-wms-cql-filter-id-xxx-works-but-id-in-xxx-does-not, in which case, change your CQL

from: id in (‘R403139’)
to: “id” in (‘R403139’)

Peter

On Sat, 10 Feb 2024 at 16:19, <wambacher@anonymised.com.> 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

Hi Peter,

that works well :slight_smile:

thanks

walter

···

Am 10.02.24 um 17:11 schrieb Peter Smythe:

Hi Wambacher

You might be running into this issue: https://gis.stackexchange.com/questions/373005/geoserver-wms-cql-filter-id-xxx-works-but-id-in-xxx-does-not, in which case, change your CQL

from: id in (‘R403139’)
to: “id” in (‘R403139’)

Peter


My projects:

OSM Software Watchlist
OSM Emergency Map ()
OSM Healthcare Map (
)
OSM Postcode Map (Germany)

*) Europe

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

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

image.png

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:

image.png

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,

image.png

and

image.png

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

···


Jody Garnett

I believe that id has always been special for WFS data sets (along with name) as the GML spec specifies them so they are automagically removed from any features that are returned

Ian

image.png

···


Jody Garnett

Ian Turton

peters answer: use *“id” in (‘R403139’)*is workind fine.

walter

···

Am 10.02.24 um 20:30 schrieb Jody Garnett:

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@anonymised.com> 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


My projects:

OSM Software Watchlist
OSM Emergency Map ()
OSM Healthcare Map (
)
OSM Postcode Map (Germany)

*) Europe

peters answer: use *“id” in (‘R403139’)*is workind fine.

walter

image.png

image.png

image.png

image.png

···

Am 11.02.24 um 13:01 schrieb Ian Turton:

I believe that id has always been special for WFS data sets (along with name) as the GML spec specifies them so they are automagically removed from any features that are returned

Ian

On Sun, 11 Feb 2024 at 07:59, Peter Smythe <gs@anonymised.com> wrote:

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

image.png

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:

image.png

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,

image.png

and

image.png

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@anonymised.com> 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@anonymised.com> 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

Ian Turton


My projects:

OSM Software Watchlist
OSM Emergency Map ()
OSM Healthcare Map (
)
OSM Postcode Map (Germany)

*) Europe

peters answer: use “id” in (‘R403139’) is workind fine.

walter

image.png

image.png

image.png

image.png

···

Am 11.02.24 um 13:01 schrieb Ian Turton:

I believe that id has always been special for WFS data sets (along with name) as the GML spec specifies them so they are automagically removed from any features that are returned

Ian

On Sun, 11 Feb 2024 at 07:59, Peter Smythe <gs@anonymised.com> wrote:

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

image.png

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:

image.png

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,

image.png

and

image.png

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@anonymised.com> 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@anonymised.com> 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

Ian Turton


My projects:

OSM Software Watchlist
OSM Emergency Map ()
OSM Healthcare Map (
)
OSM Postcode Map (Germany)

*) Europe

peters answer: use *“id” in (‘R403139’)*is workind fine.

e.g.:

cql_filter=“id” in(‘R51477’,‘R62611’,‘R2145268’,‘R62422’,‘R62504’,‘R62718’,‘R62782’,

R62650’,‘R28322’,‘R62771’,‘R62761’,‘R62341’,‘R62372’,‘R62467’,‘R62607’,‘R51529’,‘R62366’)

···

Am 10.02.24 um 17:11 schrieb Peter Smythe:

Hi Wambacher

You might be running into this issue: https://gis.stackexchange.com/questions/373005/geoserver-wms-cql-filter-id-xxx-works-but-id-in-xxx-does-not, in which case, change your CQL

from: id in (‘R403139’)
to: “id” in (‘R403139’)

Peter

On Sat, 10 Feb 2024 at 16:19, <wambacher@anonymised.com> 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


My projects:

OSM Software Watchlist
OSM Emergency Map ()
OSM Healthcare Map (
)
OSM Postcode Map (Germany)

*) Europe

What a great bit of troubleshooting everyone; let’s try and capture that for the user-docs (to prevent future confusion).

The user docs are here: https://docs.geoserver.org/main/en/user/filter/ecql_reference.html#temporal-predicate

It links to the following which is clear https://github.com/geotools/geotools/blob/main/modules/library/cql/ECQL.md, so I expect the geoserver docs are just a little outdated.

I have made a small pull-request to clarify this topic: https://github.com/geoserver/geoserver/pull/7413

image.png

···


Jody Garnett


Jody Garnett

Ian Turton

Thanks Ian

I checked, name does not appear to suffer from the same problem as id:

image.png

http://localhost:8080/geoserver/ows?service=WFS&version=1.0.0&request=GetFeature&typeNames=topp:states&outputFormat=json&cql_filter=name+IN+('Washington’) returns the 1 record, as expected.

image.png

As a result, I have only included id in the documentation warning:

https://github.com/geoserver/geoserver/pull/7414

image.png

image.png

image.png

image.png

···

Peter

GeoServer PSC
AWS Solutions Architect
https://github.com/petersmythe


Jody Garnett

Ian Turton

Hi,

Please try with WFS 2.0, I think that the name thing is connected to GML 3.x versions.

-Jukka Rahkonen-

~WRD000.jpg

image.png

image.png

image.png

image.png

image.png

image.png

···

Lähettäjä: Peter Smythe <gs@…8839…>
Lähetetty: maanantai 12. helmikuuta 2024 13.16
Vastaanottaja: Ian Turton <ijturton@…84…>
Kopio: wambacher@…9782…; geoserver-devel geoserver-devel@lists.sourceforge.net; Geoserver-users@lists.sourceforge.net
Aihe: Re: [Geoserver-users] [Geoserver-devel] trouble with cql_filter

Lähettäjä poisti kuvan.

Thanks Ian

I checked, name does not appear to suffer from the same problem as id:

http://localhost:8080/geoserver/ows?service=WFS&version=1.0.0&request=GetFeature&typeNames=topp:states&outputFormat=json&cql_filter=name+IN+('Washington’) returns the 1 record, as expected.

As a result, I have only included id in the documentation warning:

https://github.com/geoserver/geoserver/pull/7414

Peter

GeoServer PSC
AWS Solutions Architect
https://github.com/petersmythe

On Sun, 11 Feb 2024 at 14:01, Ian Turton <ijturton@…84…> wrote:

I believe that id has always been special for WFS data sets (along with name) as the GML spec specifies them so they are automagically removed from any features that are returned

Ian

On Sun, 11 Feb 2024 at 07:59, Peter Smythe <gs@…8839…> wrote:

Lähettäjä poisti kuvan.

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

Ian Turton

Hi Jukka

Repeating the test on WFS 2.0.0 on layer sf:bugsites:

image.png

http://localhost:8080/geoserver/ows?service=WFS&version=2.0.0&request=GetFeature&typenames=sf:bugsites&outputFormat=json&cql_filter=name+IN+(‘Beetle%20site’)

also appears to work just fine:

image.png

~WRD000.jpg

image.png

image.png

image.png

image.png

image.png

image.png

···

Peter

GeoServer PSC
AWS Solutions Architect
https://github.com/petersmythe

Hi,

Ok, “name” seems to be accepted in cql_filter and json output. Maybe there is still an issue (or something to know) with the GML output as explained here wfs - GeoServer DescribeFeatureType response missing attribute for GML only - Geographic Information Systems Stack Exchange

-Jukka Rahkonen-

image.png

image.png

~WRD000.jpg

image.png

image.png

image.png

image.png

image.png

image.png

···

Lähettäjä: Peter Smythe <gs@…8839…>
Lähetetty: maanantai 12. helmikuuta 2024 13.58
Vastaanottaja: Rahkonen Jukka <jukka.rahkonen@…6847…>
Kopio: wambacher@…9782…; geoserver-devel geoserver-devel@lists.sourceforge.net; Ian Turton <ijturton@…84…>; Geoserver-users@lists.sourceforge.net
Aihe: Re: [Geoserver-users] [Geoserver-devel] trouble with cql_filter

Hi Jukka

Repeating the test on WFS 2.0.0 on layer sf:bugsites:

http://localhost:8080/geoserver/ows?service=WFS&version=2.0.0&request=GetFeature&typenames=sf:bugsites&outputFormat=json&cql_filter=name+IN+(‘Beetle%20site’)

also appears to work just fine:

Peter

GeoServer PSC
AWS Solutions Architect
https://github.com/petersmythe

On Mon, 12 Feb 2024 at 13:22, Rahkonen Jukka <jukka.rahkonen@…6847…> wrote:

Hi,

Please try with WFS 2.0, I think that the name thing is connected to GML 3.x versions.

-Jukka Rahkonen-

Lähettäjä: Peter Smythe <gs@…8839…>
Lähetetty: maanantai 12. helmikuuta 2024 13.16
Vastaanottaja: Ian Turton <ijturton@…84…>
Kopio: wambacher@…9782…; geoserver-devel <geoserver-devel@lists.sourceforge.net>; Geoserver-users@lists.sourceforge.net
Aihe: Re: [Geoserver-users] [Geoserver-devel] trouble with cql_filter

Lähettäjä poisti kuvan.

Thanks Ian

I checked, name does not appear to suffer from the same problem as id:

http://localhost:8080/geoserver/ows?service=WFS&version=1.0.0&request=GetFeature&typeNames=topp:states&outputFormat=json&cql_filter=name+IN+('Washington’) returns the 1 record, as expected.

As a result, I have only included id in the documentation warning:

https://github.com/geoserver/geoserver/pull/7414

Peter

GeoServer PSC
AWS Solutions Architect
https://github.com/petersmythe

On Sun, 11 Feb 2024 at 14:01, Ian Turton <ijturton@…84…> wrote:

I believe that id has always been special for WFS data sets (along with name) as the GML spec specifies them so they are automagically removed from any features that are returned

Ian

On Sun, 11 Feb 2024 at 07:59, Peter Smythe <gs@…8839…> wrote:

Lähettäjä poisti kuvan.

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

Ian Turton

That’s a very interesting bug/feature/issue described in the Stack Exchange question. Thank you. Its impact on DescribeFeatureType and GetFeature should probably be documented with a similar warning.

FYI, I did try both JSON and XML output formats, and both did include the name attribute, however I did not notice that for XML, the namespace unexpectedly changed from sf to gml, and this would be applicable for these 5 attributes:

  • name
  • description
  • identifier
  • descriptionReference
  • metaDataProperty
  • (but not id, that is a separate issue)

See:

image.png

Andrea’s answer: https://gis.stackexchange.com/a/388397

image.png

image.png

~WRD000.jpg

image.png

image.png

image.png

image.png

image.png

image.png

···

Peter

GeoServer PSC
AWS Solutions Architect
https://github.com/petersmythe

Thanks Ian

I checked, name does not appear to suffer from the same problem as id:

image.png

http://localhost:8080/geoserver/ows?service=WFS&version=1.0.0&request=GetFeature&typeNames=topp:states&outputFormat=json&cql_filter=name+IN+('Washington’) returns the 1 record, as expected.

image.png

As a result, I have only included id in the documentation warning:

https://github.com/geoserver/geoserver/pull/7414

(attachments)

image.png
image.png
image.png
image.png

···

Peter

GeoServer PSC
AWS Solutions Architect
https://github.com/petersmythe


Jody Garnett

Ian Turton

Hi Jukka

Repeating the test on WFS 2.0.0 on layer sf:bugsites:

image.png

http://localhost:8080/geoserver/ows?service=WFS&version=2.0.0&request=GetFeature&typenames=sf:bugsites&outputFormat=json&cql_filter=name+IN+(‘Beetle%20site’)

also appears to work just fine:

image.png

(attachments)

~WRD000.jpg
image.png
image.png
image.png
image.png
image.png
image.png

···

Peter

GeoServer PSC
AWS Solutions Architect
https://github.com/petersmythe

That’s a very interesting bug/feature/issue described in the Stack Exchange question. Thank you. Its impact on DescribeFeatureType and GetFeature should probably be documented with a similar warning.

FYI, I did try both JSON and XML output formats, and both did include the name attribute, however I did not notice that for XML, the namespace unexpectedly changed from sf to gml, and this would be applicable for these 5 attributes:

  • name
  • description
  • identifier
  • descriptionReference
  • metaDataProperty
  • (but not id, that is a separate issue)

See:

image.png

Andrea’s answer: https://gis.stackexchange.com/a/388397

(attachments)

image.png
image.png
~WRD000.jpg
image.png
image.png
image.png
image.png
image.png
image.png

···

Peter

GeoServer PSC
AWS Solutions Architect
https://github.com/petersmythe