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 an "IN" operator similar to SQL in OGC Filter Encoding Standard. Combining multiple PropertyIsEqualTo operators performs really poorly.


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 http://geoserver.org/display/GEOSDOC/WMS+vendor+parameters

  • 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
  • 2
    switch to post instead of get. – Ian Turton 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? – Ian Turton 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="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd" xmlns:ogc="http://www.opengis.net/ogc" xmlns:wfs="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <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.

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