> For the complete documentation index, see [llms.txt](https://olivers-expression-lab.gitbook.io/filter-expressions-in-fme/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://olivers-expression-lab.gitbook.io/filter-expressions-in-fme/introduction.md).

# Introduction

<figure><img src="/files/S3vnd1kPZKUrhwuRXUj2" alt=""><figcaption><p>[L|W]izard of Ex</p></figcaption></figure>

This tutorial will show you how to use **filter expressions in FME** in order to query OGC Web Feature Services (**WFS**).

The relevant **Filter Encoding Standard** is developed by OGC and ISO TC/211. This standard describes a key value pair (KVP) system using XML documents.

FME supports all versions of WFS, i.e. versions 1.x, 2.x and 3.x also known as OGC API - FEATURES. So why could it be necessary to use filter expressions? What is the benefit comparing to FME standard functionality?

The answer is: most WFS services are limited to a certain number of features, normally to 10.000 or 30.000 features.

Imagine you want to use a WFS delivering cadastral parcels and you only need one or a small number of cadastral parcel features. Let's say you're using the cadastral parcel WFS of North Rhine-Westphalia which actually holds available more than 9.000.000 features. How to get the one feature with cadastral parcel number "05430202600946\_\_\_\_\_\_"?

One possible strategy could be to download the whole bunch to your local hard drive first (good luck!) and to do the selection in a second step for example using FMEs TestFilter transformer.

A more effective way could be to ask the WFS for the concrete features you need. This saves time, network traffic and local disk space.

Asking a system for a subset of data ... this reminds you of something known?

Yes, you're right! Think about **SQL** (**S**tructured **Q**uery **L**anguage). SQL is a standard language for storing, manipulating and retrieving data in databases. To query a database for a concrete dataset you'll use the key value pair "attribute = value", e.g.

```plsql
   SELECT
        *
   FROM
        cadastral_parcels
   WHERE
        parcel_number = '05430202600946______'
   ;
```

Filter expressions are working the same way: they use key value pairs.&#x20;

These keys can be:

1. attributes
2. spatial operators
3. a combination of both (attributive and spatial)

The difference to SQL is: filter expressions are written in XML (Don: we still love XML!). A key value pair may look like this:

```xml
<fes:ValueReference>parcel_number</fes:ValueReference>
<fes:Literal>05430202600946______</fes:Literal>
```

You may wonder about how this could work? Something is missing ...

Indeed: we need an operator or function like the equal sign "=" in SQL.&#x20;

<pre class="language-xml"><code class="lang-xml">&#x3C;fes:PropertyIsEqualTo>   
   &#x3C;fes:ValueReference>parcel_number&#x3C;/fes:ValueReference>
<strong>   &#x3C;fes:Literal>05430202600946______&#x3C;/fes:Literal>
</strong>&#x3C;/fes:PropertyIsEqualTo>
</code></pre>

*PropertyIsEqualTo* is the equivalent to "*=*" in SQL.

But before we're diving into the deep, I've to express my gratitude to some people.
