1

I am trying to write a WFS getfeature query for some GeoServer JSON data that returns features that match a part of a string only if the entire word matches. The word can be in the start, middle, or end of the string. I started by using cql_filter, but am returning records that don't match a whole word.

Say I have two features with the following values for AddLocID:

id, AddLocID  
1,  216  
2,  216 72216  
3,  72216 

I want to return features 1 & 2 and not feature 3

Using cql_filter=AddLocID=216 returns only feature 1 and does not match feature 2

https://bloomington.in.gov/geoserver/publicgis/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=publicgis:HistoricSitesandStructuresSurvey2018&cql_filter=AddLocID=216&outputFormat=application%2Fjson

Using cql_filter=AddLocID Like 216 returns all 3 features but I only want 1 and 2

https://bloomington.in.gov/geoserver/publicgis/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=publicgis:HistoricSitesandStructuresSurvey2018&cql_filter=AddLocIDlike%27%216%%27&outputFormat=application%2Fjson

How can a write my query so that records 1 and 2 are return that match 216 as a whole word in the string value?

2

You can use the isLike function which takes a full Java Rexep for the match. In your case you could use something like:

cql_filter=isLike("AddLocID",'.*\b216\b.*')=true

so that \b matches a word boundary. You may need to experiment with just how many \ will be required for it to work.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.