Test the VB CQL Parser

Enter sample query: Strict

In 'strict' mode a query must conform to the BNF Version 1.1 Definition of CQL or it will fail.

In normal or 'non-strict' mode, a booleanGroup may have empty modifiers. This is to support the old style prox syntax, such as foo prox///sentence bar which allowed empty modifiers. Normal mode also supports an optional syntax where a searchTerm may actually contain multiple searchTerms inside of parenthesis, such as title = ((dinosaur and bird) or dinobird). This is a shorthand notation which is equivalent to ((title = dinosaur and title = bird) or title = dinobird) which may be supported in an official future version of the CQL syntax.

Queries marked with *** are not compliant with the 1.1 version of CQL BNF and will fail in 'strict' mode.

Questions or comments about this service should be directed to Tom Habing at the Grainger Engineering Library Information Center, University of Illinois at Urbana-Champaign.

From CQL - Common Query Language - ZING (Library of Congress)

dc.title
cql.stem
dc.title = "cat"
cat
dc.title = "cat"
author = "smith"
dc.title any "cat"
bath.author cql.exact "smith, j."
dc.title any/relevant/rel.CORI "cat fish"
dc.author exact/stem "smith, j."
dc.title = cat
"<element>"
dc.title = "cat" and bath.author = "smith"
" cat" or hat
dc.title = "cat" prox/distance=1/unit=word dc.title = "in"
"cat" prox/distance>2/ordered "hat"
dc.title=cat and/rel.sum dc.title=dog
> dc="http://www.dublincore.org/" dc.title = "cat"
cql.resultSetId = "resultA" and cql.resultSetId = "resultB"

From CQL: Sample Searches

Simple Term

cat
"cat"
comp.os.linux
ml:element
"<xml:element>"
"="
"prox/distance<3/unit=word"
("cat")
((dog))
all
prox

Index Relation Term

title = "fish"
title exact fish
title any fish
title all fish
title > 9
title >= 23
dc.title any "fish chips"
dc.title any/stem fish
dc.fish all/stem/fuzzy "fish chips"
(title any frog)
((dc.title any/stem "frog pond"))
dc.title scr "fish frog chicken"
dc.title =/rel.algorithm=CORI squid
creator any/f.foo/b.bar>1 "sanderson taylor"

Simple Boolean

cat or dog
cat and fish
cat not frog
(cat not frog)
"cat" not "fish food"
xml and "prox///"
fred and any
((fred or all))
a or b and c not d

Index Relation Term plus Boolean

bath.uniformTitle any fish and dc.title any "cat dog"
(title any/stem "fish dog" or and)

Proximity and Boolean Modifiers

cat prox hat
cat prox/distance=3/unit=word/ordered hat
cat prox/distance<3 hat
"fish food" prox/unit=sentence and
title all "chips frog" prox/distance<=5 exact
(dc.author exact "jones" prox/distance>5/unit=element title >= "smith")
a and/rel.SumOfScores b
a and/rel.algorithm=CORI b

Special Characters

(cat^)
"cat"
"^cat says \"fish\""
"cat*fish"
cat?dog
(("^cat*fishdog\"horse?"))

Nesting Parentheses

(((cat or dog) or horse) and frog)
(cat and dog) or (horse and frog)
(cat and (horse or frog)) and chips

Prefix Maps

> foo="info:srw/cql-context-set/1/dc-v1.1" dc.title="fish"
> "info:srw/cql-context-set/1/dc-v1.1" title="fish"
> foo="info:srw/cql-context-set/1/dc-v1.1" > ccg = "http://srw.cheshire3.org/contextSets/ccg/1.1/" foo.title="fish" and ccg.force=3

Lame Searches

any or all:stem and all exact any prox prox=fuzzy
(((((((((any)))))))))
""
> any > any = exact any > any

Invalid searches [should error]

<
===
missingClause or
missingTerm any
()
(missingParen
missingParen any fish)
(emptyParens or ())
title = ("illegal parentheses") STRICT
> illegal="urn:missingQuery"

From ZING - A Gentle Introduction to CQL

Simple queries

fish
dinosaur
comp.sources.misc
"dinosaur"
"complete dinosaur"
"the complete dinosaur"
"ext->u.generic"
ext->u.generic
"and"

Booleans

dinosaur or bird
dinosaur not reptile
dinosaur and bird and reptile
dinosaur and bird or dinobird
(bird or dinosaur) and (feathers or scales)
"feathered dinosaur" and (yixian or jehol)
(((a and b) or (c not d) not (e or f and g)) and h not i) or j
foo and bar or baz
foo or bar and baz
(foo and bar) or baz
(foo or bar) and baz
foo and (bar or baz)
foo or (bar and baz)
foo and (bar or baz)
(foo) and (bar or baz)
(foo) and ((bar) or (baz))
(foo) and ((bar) or (baz))
(((((foo))) and (((((((((((((bar)))))))))))) or (baz))))

Proximity

complete prox dinosaur
(caudal or dorsal) prox vertebra
*** ribs prox//5 chevrons STRICT
*** ribs prox//0/sentence chevrons STRICT
*** ribs prox/>/0/paragraph chevrons STRICT
foo prox bar
*** foo prox///sentence bar STRICT
*** foo prox//3/element bar STRICT
*** foo prox/=/2/paragraph bar STRICT
*** foo prox/>/4/word/ordered bar STRICT

Indexes

title=dinosaur
title = dinosaur
*** title = ((dinosaur and bird) or dinobird) STRICT
dc.title = saurischia
bath.title="the complete dinosaur"
srw.serverChoice=foo
srw.resultSet=bar
bib.title = "Zen and the Art of Motorcycle Maintenance"
heraldry.title=viscount

Index-Set Mapping

>dc="http://www.loc.gov/srw/index-sets/dc" dc.title=dinosaur and dc.author=farlow
(>x="http://www.loc.gov/srw/index-sets/dc" x.title=dinosaur) and (>aVerySillyLongPrefix="http://www.loc.gov/srw/index-sets/dc" aVerySillyLongPrefix.author=farlow)
>"http://www.loc.gov/srw/index-sets/dc" title=dinosaur and author=farlow

Relations

year > 1998
title all "complete dinosaur"
title any "dinosaur bird reptile"
title exact "the complete dinosaur"
publicationYear < 1980
numberOfWheels <= 3
numberOfPlates = 18
lengthOfFemur > 2.4
bioMass >= 100
numberOfToes <> 3
title=dinosaur
title =dinosaur
title= dinosaur
title = dinosaur
title = dinosaur

Relation Modifiers

title all/stem "complete dinosaur"
title any / relevant "dinosaur bird reptile"
title exact/fuzzy "the complete dinosaur"
author = /fuzzy tailor
telephoneNumber exact/fuzzy "0208 346 6797"

Pattern Matching

dinosaur*
*sauria
man?raptor
man?raptor*
"the comp*saur"
char\*

Word Anchoring

title="^the complete dinosaur"
author="bakker^"
author all "^kernighan ritchie"
author any "^kernighan ^ritchie ^thompson"

Bit by bit, putting it together

*** dc.author=(kern* or ritchie) and (bath.title exact "the c programming language" or dc.title=elements prox///4 dc.title=programming) and subject any/relevant "style design analysis" STRICT

From search.cpan.org: CQL::Parser - compiles CQL strings into parse trees of Node subtypes.

george
dc.creator=george
dc.creator="George Clinton"
clinton and funk
clinton and parliament and funk
(clinton or bootsy) and funk
dc.creator="clinton" and dc.date="1976"

Bonus Queries

Invalid Queries

prox and/or <dc:title>and or</dc:title> and or

Valid Queries

"a b" "c \"d" /fuzzy="1 2" "e f"
PI ratio/approx "22/7"