camptocamp / GeoMapFish

6 stars 1 forks source link

Add a new ilike operator in the filter #61

Open yjacolin opened 2 years ago

yjacolin commented 2 years ago

Who requested this new feature?

Tadao, @andre-simoes

Is your feature request related to a problem?

No

Describe the solution you'd like

Use case is to search in filter module for an exact term without taking care of the casse. For instance exact match of 'Lens' should find 'LENS', 'lens' but not 'Somethin-on-Lens'.

Additional information or points to watch out for

Namely, for this "filter" functionality we add a filter to the OGC FilterEncoding standard in the query.

In the case of a "commune = Lens" we use :

<PropertyIsEqualTo>
    <PropertyName>commune</PropertyName>
    <Literal>Lens</Literal>
</PropertyIsEqualTo>

And in this case indeed we have no results.

In the case of a "contains" we use :

<PropertyIsLike wildCard="*" singleChar="." escapeChar="!" matchCase="false">
    <PropertyName>commune</PropertyName>
    <Literal>*Lens*</Literal>
</PropertyIsLike>

We took a look at the corresponding standard, from a purely XML point of view, the matchCase="False" seems valid in a PropertyIsEqualTo.

But obviously it is not applied on the QGIS Server side, which we understand because it doesn't really make sense (it is not possible to ignore case with an "=" in PostgreSQL either).

To achieve our goal we would have to do the same thing as for contains but in the "*" in Literal, e.g. :

<PropertyIsLike wildCard="*" singleChar="." escapeChar="!" matchCase="false">
    <PropertyName>commune</PropertyName>
    <Literal>Lens</Literal>
</PropertyIsLike>

In the case of the "contains", these stars are automatically and systematically placed here for the user's convenience and we don't see any way to remove them in the existing operator.

We don't see a simple way to do a case-insensitive "=", unless you add a new client-side operator to GMF, like "ilike" which uses PropertyIsLike but doesn't automatically add the stars.