2

I am trying to query GeoServer with a CQL Filter using the IN clause.

If I send a request like this I get data back.

http://server.com/geoserver/server/wfs?service=wfs&version=1.0.0&request=getfeature&typename=server:states&CQL_FILTER=state_name%20in%20(%27Texas%27)&outputFormat=application/json

but if I send a url with strToLowerCase around state_name it will not work.

http://server.com/geoserver/server/wfs?service=wfs&version=1.0.0&request=getfeature&typename=server:states&CQL_FILTER=strToLowerCase(state_name)%20in%20(%27Texas%27)&outputFormat=application/json

Is there anyway around this?

2
  • You are comparing lower-case state names with Texas (capital T), so you can expect to get no result
    – JGH
    May 25, 2018 at 15:07
  • Sorry messed up the second url. It should be server.com/geoserver/server/… I reccieved the same error that you noted below in your comment.
    – mkeller
    May 25, 2018 at 15:46

1 Answer 1

2

Looking at the logs, CQL does't accept IN after strToLoweCase

Caused by: org.geotools.filter.text.cql2.CQLException: Encountered "in" at line 1, column 28. Was expecting one of:
    <EOF> 
    "and" ...
    "or" ...
    ";" ...
    "*" ...
    "/" ...
    "+" ...
    "-" ...
    "not" ...
    "like" ...
    "ilike" ...
    "exists" ...
    "does-not-exist" ...
    "is" ...
    "between" ...
    "=" ...
    ">" ...
    "<" ...
    ">=" ...
    "<=" ...
    "<>" ...
     Parsing : strToLowerCase(STATE_NAME) in ('texas','abc').

So you would have to use = and or

 strToLowerCase(STATE_NAME) = 'texas' or strToLowerCase(STATE_NAME) = 'florida'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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