Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a good way to filter datasets with approx 50,000 features in Geoserver? I'd have to select between 100 and 200 features based on ids. These ids are different from the FeatureIds. Couldn't find a "IN" operator similar to SQL in OGC Filter Encoding Standard. Combining multiple PropertyIsEqualTo operators performs really poorly.

share|improve this question
up vote 7 down vote accepted

Ah. In that case, you could use GeoServer's WMS CQL filter support, i.e.:

http://<hostname>/wms?service=WMS&version=1.1.1&request=GetMap&....&cql_filter=IN ('id_1','id_2','id_3')

More information is available at

share|improve this answer
Great! Didn't know that there is an IN operator in CQL. While trying this with "=" operator, Apache ran into "414 Request-URI Too Long". Maybe the characters saved this way make a difference. – underdark Sep 2 '10 at 18:24
switch to post instead of get. – iant Sep 4 '10 at 14:55
@iant: You're right, POST instead of GET works. The performance remains poor though. – underdark Sep 7 '10 at 16:27
do you have an index on the FIDs column? – iant Sep 7 '10 at 17:11
@iant: I have an index on the id I'm filtering for, but not on the FIDs. – underdark Sep 9 '10 at 21:27

You could pass a list of feature id's in the following manner:




<?xml version="1.0" encoding="UTF-8"?>
<wfs:GetFeature version="1.1.0" outputFormat="text/xml; subtype=gml/3.1.1" service="WFS" resultType="results" xsi:schemaLocation="" xmlns:ogc="" xmlns:wfs="" xmlns:xsi="">
    <wfs:Query typeName="foo">
            <ogc:FeatureId fid="id_1"/>
            <ogc:FeatureId fid="id_2"/>
            <ogc:FeatureId fid="id_3"/>

The POST option is obviously more verbose, but less than looping PropertyIsEqualTo constructs.

share|improve this answer
That looks like a good solution for filtering FeatureIds. Unfortunately, the ids I have to filter (results of a different party's algorithm) are not same as the FeatureIds. I updated the question. – underdark Sep 2 '10 at 15:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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