I am setting up a query against a layer on my GeoServer instance. My query string can become quite complex, and some statements require using multiple '%' wildcards.

For starter's here's an example:

Search for Property Owner: ___________

If the user types in 'Smith', I need to find values that meet the following criteria:

CQL_FILTER=Owner ilike '%Smith%'

However, this is returning all features in my layer.

In fact, when I use just one wildcard, ex. 'Smith%', I still get all features.

What makes this even more difficult is when my query string becomes quite lengthy:

CQL_FILTER=Owner ilike '%Smith%' AND Address ilike '%Main%' AND Value < 100000

Reading the GeoServer docs, I see the wildcard is supported in CQL/ECQL. The syntax is very close to SQL which I have used in the past to do the very same queries.

Anyone have an idea what may be causing this issue? Anyone else have much luck using wildcards in their CQL filters?

Thanks in advance!


You have not posted a complete example of the url you are building and sending to GeoServer so it is difficult to know for sure what the problem is. However, I suspect the problem lies in the use of the % for the wildcard.

In a url the % character has a special meaning as it is used when certain characters should be encoded. For example, you may well recall seeing %20 as part of a url in the past, this is an encoding for a space. If you are using the url method then you need to make sure your CQL_FILTER parameter is properly encoded. In the example you give it would need to be:


The other thing to consider is case-sensitivity of your attribute names. If your data back-end cares about case then you need to make sure the case is correct in the CQL_FILTER. For example, if the data back-end is PostGIS then there would be a difference in result between Owner, OWNER, and owner. Likewise for the Value attribute.

| improve this answer | |
  • 1
    +1 CQL filters are tricky buggers. Casing has tripped me up a few times, as has encoding. – Rob Quincey Nov 8 '13 at 11:03
  • Encoding was the issue. I was not using encodeURI on the entire query. Also, thanks for the information on case-sensitivity. It wasn't an issue for me, but I'm sure others will run into that. Thanks again! – evv_gis Nov 8 '13 at 17:14
  • I have the same problem where it is not working... equal operator is working but like is not working – Curiosity Mar 24 '17 at 11:20
  • I tried with encodeURI and encodeURIComponent but no luck. – Curiosity Mar 24 '17 at 11:21
  • Though it is working in geoserver layer preview but not working in code – Curiosity Mar 24 '17 at 11:22

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.