ECQL Reference¶
This section provides a reference for the syntax of the ECQL language. The full language grammar is documented in the the GeoTools ECQL BNF definition
Syntax Notes¶
The sections below describe the major language constructs. Each construct lists all syntax options for it. Each option is defined as a sequence of other constructs, or recursively in terms of itself.
Symbols which are part of the ECQL language are shown in
code font
. All other symbols are part of the grammar description.ECQL keywords are not casesensitive.
A vertical bar symbol ‘’ indicates that a choice of keyword can be made.
Brackets ‘[ … ]’ delimit syntax that is optional.
Braces ‘{ … }’ delimit syntax that may be present zero or more times.
Condition¶
A filter condition is a single predicate, or a logical combination of other conditions.
Syntax 
Description 
Single predicate expression 

Conjunction or disjunction of conditions 


Negation of a condition 

Bracketing with 
Predicate¶
Predicates are booleanvalued expressions which specify relationships between values.
Syntax 
Description 
Expression 
Comparison operations 
Expression [ 
Tests whether a value lies in or outside a range (inclusive) 
Expression [ 
Simple pattern matching.
likepattern uses the 
Attribute [ 
Tests whether an expression value is (not) in a set of values 
Tests whether a feature ID value is in a given set. ID values are integers or string literals 

Expression 
Tests whether a value is (non)null 
Attribute 
Tests whether a featuretype does (not) have a given attribute 

Always include (exclude) features to which this filter is applied 
Temporal Predicate¶
Temporal predicates specify the relationship of a timevalued expression to a time or time period.
Syntax 
Description 
Expression 
Tests whether a time value is before a point in time 
Expression 
Tests whether a time value is before or during a time period 
Expression 
Tests whether a time value is during a time period 
Expression 
Tests whether a time value is during or after a time period 
Expression 
Tests whether a time value is after a point in time 
Spatial Predicate¶
Spatial predicates specify the relationship between geometric values.
Topological spatial predicates
(INTERSECTS
, DISJOINT
, CONTAINS
, WITHIN
,
TOUCHES
CROSSES
, OVERLAPS
and RELATE
)
are defined in terms of the DE9IM model described in the
OGC Simple Features for SQL specification.
Syntax 
Description 

Tests whether two geometries intersect.
The converse of 

Tests whether two geometries are disjoint.
The converse of 

Tests whether the first geometry topologically contains the second.
The converse of 

Tests whether the first geometry is topologically within the second.
The converse of 

Tests whether two geometries touch. Geometries touch if they have at least one point in common, but their interiors do not intersect. 

Tests whether two geometries cross. Geometries cross if they have some but not all interior points in common 

Tests whether two geometries overlap. Geometries overlap if they have the same dimension, have at least one point each not shared by the other, and the intersection of the interiors of the two geometries has the same dimension as the geometries themselves 

Tests whether two geometries are topologically equal 

Tests whether geometries have the spatial relationship specified by a DE9IM matrix pattern.
A DE9IM pattern is a string of length 9 specified using the characters 

Tests whether the distance between two geometries is no more than the specified distance.
distance is an unsigned numeric value for the distance tolerance.
units is one of 

Similar to 

Tests whether a geometry intersects a bounding box
specified by its minimum and maximum X and Y values.
The optional CRS is a string containing an SRS code
(For example, 
Expression¶
An expression specifies a attribute, literal, or computed value. The type of the value is determined by the nature of the expression. The standard PEMDAS order of evaluation is used.
Syntax 
Description 
Name of a feature attribute 

Literal value 

Expression 
Arithmetic operations 
function 
Value computed by evaluation of a filter function with zero or more arguments. 

Bracketing with 
Attribute¶
An attribute name denotes the value of a feature attribute.
Simple attribute names are sequences of letters and numbers,
Attribute names quoted with doublequotes may be any sequence of characters.
Literal¶
Literals specify constant values of various types.
Type 
Description 
Number 
Integer or floatingpoint number. Scientific notation is supported. 
Boolean 

String 
String literal delimited by single quotes. To include a single quote in the
string use two singlequotes: 
Geometry 
Geometry in WKT or EWKT format.
WKT is defined in the OGC Simple Features for SQL specification.
All standard geometry types are supported:

Time 
A UTC date/time value in the format 
Duration 
A time duration specified as 