I am using OpenLayers to connects to QGIS Server, to serve a WMS layers.

I want to filter the WMS layer according to one attribute. I have followed the documentation to do so. Everything is working fine if I use the '=' operator, like the following, for example:

FILTER=myLayerName: "myAttribute" = 1

But I need to have the criteria using the 'IN' operator, because I am filtering on multi values, like the following, for example (doesn't work)

FILTER=myLayerName: "myAttribute" IN (1, 2, 3)

Could you please advice me with the proper way to use the 'IN' operator with Integer values?


It might be too late, but still : I ran into the same problem and eventually found this page, where it es explained that

Text strings need to be enclosed with quotes (single quotes for strings, double quotes for attributes) A space between each word / special character is mandatory. Allowed Keywords and special characters are ‘AND’,’OR’,’IN’,’=’,’<’,’>=’, ‘>’,’>=’,’!=*,’(‘,’)’. Semicolons in string expressions are not allowed

I tried it on my own QGIS 3.4 server and I could make work something like

FILTER=mylayername:"attribute1" = 'value1' AND "attribute2" < 10000

I believe that in your case, the problem is that your query should look like :

FILTER=myLayerName: "myAttribute" IN ( 1 , 2 , 3 )

i.e. with spaces between each value / word / single character like the parenthesis.

| 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.