CQL-TEXT does not work with the NOCASE keyword for case (in)sensitive searches
Description
As per CQL predicates, the CQL comparisons should default nocase: true. Instead, this is ignored, and specifying NOCASE produces an error. The only way I am able to get case insensitive searches with cql-text are with ILIKE.
Steps to Reproduce Use NOCASE parameter: https://reference.geoconnex.us/collections/states/items?filter=name%20LIKE%20%27NEW%%27%20NOCASE%20true
Expected behavior name LIKE new is the same as name LIKE New is the same as name ILIKE new is the same as name LIKE new NOCASE true
Screenshots/Tracebacks

Environment
- OS: MacOS Ventura/Mac M1
- Python version: docker/3.10
- pygeoapi version: latest/0.15.0
Additional context I have not tested this with CQL-JSON or Elasticsearch.
This is confirmed with demo:
http "https://demo.pygeoapi.io/master/collections/lakes/items?f=json&filter=name LIKE '%baika%' NOCASE true"
HTTP/1.1 400 Bad Request
Access-Control-Allow-Origin: *
Content-Crs: <http://www.opengis.net/def/crs/OGC/1.3/CRS84>
Content-Language: en-US
Content-Length: 108
Content-Type: application/json
Date: Wed, 23 Aug 2023 15:33:13 GMT
Server: gunicorn
X-Powered-By: pygeoapi 0.16.dev0
{
"code": "InvalidParameterValue",
"description": "Bad CQL string : name LIKE '%BAika%' NOCASE true"
}
Neither ILIKE is working for me:
http "https://demo.pygeoapi.io/master/collections/lakes/items?f=json&filter=name ILIKE '%baika%' NOCASE true"
HTTP/1.1 400 Bad Request
Access-Control-Allow-Origin: *
Content-Crs: <http://www.opengis.net/def/crs/OGC/1.3/CRS84>
Content-Language: en-US
Content-Length: 109
Content-Type: application/json
Date: Wed, 23 Aug 2023 15:40:42 GMT
Server: gunicorn
X-Powered-By: pygeoapi 0.16.dev0
{
"code": "InvalidParameterValue",
"description": "Bad CQL string : name ILIKE '%BAika%' NOCASE true"
}
@francbartoli The mention of ILIKE should be taken separate from the CQL vocabulary for NOCASE. The CQL term NOCASE does not work. Because of how CQL is processed for Postgres, the SQL term ILIKE allows for nocase-like CQL queries.
curl -I -X GET "https://demo.pygeoapi.io/master/collections/lakes/items?f=json&filter=name%20ILIKE%20%27%baika%%27"
HTTP/2 200
access-control-allow-origin: *
content-crs: <http://www.opengis.net/def/crs/OGC/1.3/CRS84>
content-language: en-US
content-type: application/json
date: Wed, 23 Aug 2023 18:51:23 GMT
server: gunicorn
x-powered-by: pygeoapi 0.16.dev0
content-length: 39637
@webb-ben after several tests, I found out that:
- We are atm using the ecql parser
pygeofilter.parsers.ecql.parsedespite it is availablepygeofilter.parsers.cql2_text.parse. @constantinius I'm wondering if it makes sense the switch to the latter in pygeoapi -
pygeofilter.parsers.ecql.parseis supporting case sensitive by default withLIKEand case insensitive withILIKE
(Pdb) cqltext = "name LIKE '%baika%'"
(Pdb) print(pygeofilter.parsers.ecql.parse(cqltext))
Like(lhs=ATTRIBUTE name, pattern='%baika%', nocase=False, wildcard='%', singlechar='.', escapechar='\\', not_=False)
(Pdb) cqltext = "name ILIKE '%baika%'"
(Pdb) print(pygeofilter.parsers.ecql.parse(cqltext))
Like(lhs=ATTRIBUTE name, pattern='%baika%', nocase=True, wildcard='%', singlechar='.', escapechar='\\', not_=False)
- However
pygeofilter.parsers.cql2_text.parsedoesn't supportNOCASE
(Pdb) cqltext = "name LIKE '%baika%' NOCASE true"
(Pdb) print(pygeofilter.parsers.cql2_text.parse(cqltext))
*** lark.exceptions.UnexpectedToken: Unexpected token Token('__ANON_4', 'NOCASE') at line 1, column 21.
Expected one of:
* $END
* AND
* OR
Previous tokens: [Token('SINGLE_QUOTED', "'%baika%'")]
As per RFC4, this Issue has been inactive for 90 days. In order to manage maintenance burden, it will be automatically closed in 7 days.
@francbartoli Any update on this? Believe this remains unresolved.
deferring to @ricardogsilva who managed to fix some bugs on the ecql parser
This Issue has been inactive for 90 days. As per RFC4, in order to manage maintenance burden, it will be automatically closed in 7 days.
As per RFC4, this Issue has been closed due to there being no activity for more than 90 days.