metadata

The following filters match game metadata: information about a game that does not depend on an particular position:

filter name examples description
elo elo 2200 2600
elo black 2400 3000
ELO of player is in specified range
event event "Wijk" argument matches PGN event field
gamenumber gamenumber 1 1000 game number lies in range
player player "Kasparov"
player white "Euwe"
argument matches specified player name
result result 1-0
result 1/2-1/2
game result equal to argument
site site "Amsterdam" argument matches site field of game in PGN header
year year 2005 2015 year of game is in range

Metadata filters in the CQL header

Each of these can be specified in the CQL header, not just the body, e.g.
cql(input mega.pgn
    player white "Kasparov"
    elo black 2500 3000
    year 1980 1989)
mate
would find all games in which Kasparov, playing white, mated an opponent rated at least 2500 in the decade of the 1980s.

This has the same effect as putting the filters in the body, like this:

cql(input mega.pgn)
 player white "Kasparov"
 elo black 2500 3000
 year 1980 1989
 mate
)
The first formulation has the minor advantage of not testing the metadata filters at each position.

Metadata filters on the command line

The gamenumber, year, and player filters can be specified on the command line as well using the appropriate options. For example, to run CQL on only games 10 through 100, use
cql --gamenumber 10 100 cql_filename
where cql_filename is the filename of the .cql file containing the CQL commands.

See the command line options for more information on using the command line.

Sorting metadata filters

Each of the metadata filters that accept a range is sortable. The sort can be specified either in the CQL header or in the CQL body. For example, to sort games after 2000 by year, use
cql (input mega.pgn sort year 2000 2017)