# Presentation: 238437

## Saving the world through

- the wonder that is
- >>> ***CQL*** <<<
- Mike Taylor <_[mike@indexdata.com](mailto:mike@indexdata.com)_>
- Index Data – _[http://www.indexdata.com](http://www.indexdata.com/)_
- With a little help from BMNH R5937 “The Archbishop”

## Overview

- Mike Taylor, Index Data  <mike@indexdata.com>

- Where we're headed:
- Why OpenSearch rules so much

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## Overview

- Mike Taylor, Index Data  <mike@indexdata.com>

- Where we're headed:
- Why OpenSearch rules so much
- Why OpenSearch sucks so hard

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## Overview

- Mike Taylor, Index Data  <mike@indexdata.com>

- Where we're headed:
- Why OpenSearch rules so much
- Why OpenSearch sucks so hard
- CQL saves the world!

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## Overview

- Mike Taylor, Index Data  <mike@indexdata.com>

- Where we're headed:
- Why OpenSearch rules so much
- Why OpenSearch sucks so hard
- CQL saves the world!
- Why CQL is hard to implement

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## Overview

- Mike Taylor, Index Data  <mike@indexdata.com>

- Where we're headed:
- Why OpenSearch rules so much
- Why OpenSearch sucks so hard
- CQL saves the world!
- Why CQL is hard to implement
- Why CQL is easy to implement

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## Overview

- Mike Taylor, Index Data  <mike@indexdata.com>

- Where we're headed:
- Why OpenSearch rules so much
- Why OpenSearch sucks so hard
- CQL saves the world!
- Why CQL is hard to implement
- Why CQL is easy to implement
- Now what?

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## Why OpenSearch rules so much

- Mike Taylor, Index Data  <mike@indexdata.com>

- OpenSearch is great because:
- It gives clients a well-defined way to request searches
- It returns data in a well-known format

- OpenSearch
- Metasearcher

- OpenSearch
- Server 1

- Nice, coherent XML

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## Why OpenSearch rules so much

- Mike Taylor, Index Data  <mike@indexdata.com>

- OpenSearch is great because:
- It gives clients a well-defined way to request searches
- It returns data in a well-known format

- OpenSearch
- Metasearcher

- OpenSearch
- Server 1

- OpenSearch
- Server 2

- Nice, coherent XML

- Same  XML

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## Why OpenSearch rules so much

- Mike Taylor, Index Data  <mike@indexdata.com>

- OpenSearch is great because:
- It gives clients a well-defined way to request searches
- It returns data in a well-known format

- OpenSearch
- Metasearcher

- OpenSearch
- Server 1

- OpenSearch
- Server 3

- OpenSearch
- Server 2

- Nice, coherent XML

- Same  XML

- Same XML again!

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## Why OpenSearch sucks so hard

- Mike Taylor, Index Data  <mike@indexdata.com>

- OpenSearch
- Metasearcher

- OpenSearch
- Server 1

- OpenSearch
- Server 3

- OpenSearch
- Server 2

- Ghasty proprietary
- query language #1

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## Why OpenSearch sucks so hard

- Mike Taylor, Index Data  <mike@indexdata.com>

- OpenSearch
- Metasearcher

- OpenSearch
- Server 1

- OpenSearch
- Server 3

- OpenSearch
- Server 2

- Ghasty proprietary
- query language #1

- Revolting  proprietary
- query language #2

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## Why OpenSearch sucks so hard

- Mike Taylor, Index Data  <mike@indexdata.com>

- OpenSearch
- Metasearcher

- OpenSearch
- Server 1

- OpenSearch
- Server 3

- OpenSearch
- Server 2

- Ghasty proprietary
- query language #1

- Revolting  proprietary
- query language #2

- Ethically horrifying,
- foul and totally
- incomprehensible
- query language #3

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## Why OpenSearch sucks so hard

- Mike Taylor, Index Data  <mike@indexdata.com>

- OpenSearch
- Metasearcher

- OpenSearch
- Server 1

- OpenSearch
- Server 3

- OpenSearch
- Server 2

- Ghasty proprietary
- query language #1

- Revolting  proprietary
- query language #2

- Ethically horrifying,
- foul and totally
- incomprehensible
- query language #3

- !!!
- Aaaargh!
- !!!

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## CQL saves the world!

- Saving the world through CQL

- OpenSearchSRU
- Metasearcher

- SRU
- Server 1

- SRU
- Server 3

- SRU
- Server 2

- Lovely CQL

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## CQL saves the world!

- Saving the world through CQL

- OpenSearchSRU
- Metasearcher

- SRU
- Server 1

- SRU
- Server 3

- SRU
- Server 2

- Lovely  CQL

- Lovely CQL

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## CQL saves the world!

- Saving the world through CQL

- OpenSearchSRU
- Metasearcher

- SRU
- Server 1

- SRU
- Server 3

- SRU
- Server 2

- Lovely  CQL

- Lovely CQL

- Lovely CQL

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## CQL saves the world!

- Saving the world through CQL

- OpenSearchSRU
- Metasearcher

- SRU
- Server 1

- SRU
- Server 3

- SRU
- Server 2

- Lovely  CQL

- Lovely CQL

- Lovely CQL

**: –)**

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## CQL saves the world: see for yourself

- Saving the world through CQL

- European
- Library

- SRU
- Server 1

- SRU
- Server 3

- SRU
- Server 2

- Lovely  CQL

- Lovely CQL

- Lovely CQL

- Talk to Theo about this
- http://www.###

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## What if ...

- Saving the world through CQL

- OpenSearch
- Metasearcher

- OpenSearch
- Server 1

- OpenSearch
- Server 3

- OpenSearch
- Server 2

- Lovely  CQL

- Even more
- lovely CQL!
- Yum!

- Lovely CQL

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## OK, what actually is CQL?

- OK, what actually *is* CQL?

- Saving the world through CQL

- dinosaur

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## OK, what actually is CQL?

- OK, what actually *is* CQL?

- Saving the world through CQL

- dinosaur
- dinosaur and vertebra

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## OK, what actually is CQL?

- OK, what actually *is* CQL?

- Saving the world through CQL

- dinosaur
- dinosaur and vertebra
- dinosaur or pterosaur

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## OK, what actually is CQL?

- OK, what actually *is* CQL?

- Saving the world through CQL

- dinosaur
- dinosaur and vertebra
- dinosaur or pterosaur
- vertebra not dorsal

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## OK, what actually is CQL?

- OK, what actually *is* CQL?

- Saving the world through CQL

- dinosaur
- dinosaur and vertebra
- dinosaur or pterosaur
- vertebra not dorsal
- (dinosaur or pterosaur) and (vertebra not dorsal)

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## OK, what actually is CQL?

- OK, what actually *is* CQL?

- Saving the world through CQL

- dinosaur
- dinosaur and vertebra
- dinosaur or pterosaur
- vertebra not dorsal
- (dinosaur or pterosaur) and (vertebra not dorsal)
- title=churchill

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## OK, what actually is CQL?

- OK, what actually *is* CQL?

- Saving the world through CQL

- dinosaur
- dinosaur and vertebra
- dinosaur or pterosaur
- vertebra not dorsal
- (dinosaur or pterosaur) and (vertebra not dorsal)
- title=churchill
- creator=churchill

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## OK, what actually is CQL?

- OK, what actually *is* CQL?

- Saving the world through CQL

- dinosaur
- dinosaur and vertebra
- dinosaur or pterosaur
- vertebra not dorsal
- (dinosaur or pterosaur) and (vertebra not dorsal)
- title=churchill
- creator=churchill
- subject = (dinosaurs and biomechanics)

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## OK, what actually is CQL?

- OK, what actually *is* CQL?

- Saving the world through CQL

- dinosaur
- dinosaur and vertebra
- dinosaur or pterosaur
- vertebra not dorsal
- (dinosaur or pterosaur) and (vertebra not dorsal)
- title=churchill
- creator=churchill
- subject = (dinosaurs and biomechanics)
- Hey!  What's the big deal?  This is *easy*!

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## OK, what actually is CQL?

- OK, what actually *is* CQL?

- Saving the world through CQL

- People of a faint disposition might like to look away now.

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## OK, what actually is CQL?

- OK, what actually *is* CQL?

- Saving the world through CQL

- People of a faint disposition might like to look away now.
-  dc.author=(kern* or ritchie) and
-   (bath.title exact "the c programming language" or
-   dc.title=elements prox/distance=4 dc.title=programming)
-   and subject any/relevant "style design analysis"
- (Yes, that's all one query.)

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## OK, what actually is CQL?

- OK, what actually *is* CQL?

- Saving the world through CQL

- People of a faint disposition might like to look away now.
-  dc.author=(kern* or ritchie) and
-   (bath.title exact "the c programming language" or
-   dc.title=elements prox/distance=4 dc.title=programming)
-   and subject any/relevant "style design analysis"
- (Yes, that's all one query.)
- Don't try this at home, kids.  Get JavaScript to build it for you.

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## The CQL learning curve

- Saving the world through CQL

- Power of query that can be expressed

- Effort in learning query language

- SQL

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## The CQL learning curve

- Saving the world through CQL

- Power of query that can be expressed

- Effort in learning query language

- SQL

- Google

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## The CQL learning curve

- Saving the world through CQL

- Power of query that can be expressed

- Effort in learning query language

- SQL

- Google

- CQL

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## Why CQL is hard to implement

- Saving the world through CQL

- Are you kidding?  Just look at all that power:
- multi-word terms with wildcards and anchoring
- indexes (creator, title, subject ...)
- index prefixes  (dc for Dublin Core, rec for Record Metadata)
- relations (<  <=  =>  >  =  <>  exact  all any)
- relation modifiers
- booleans (and, or, not, prox)
- boolean modifiers (ouch, ouch, ouch)
- prefix mapping ... and much, much more!

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## Why CQL is easy to implement

- Saving the world through CQL

- How do you decode CGI parameters?
- 	– use a library!
- How do you parse XML?
- 	– use a library!
- How do you send an HTTP request and get the response?
- 	– use a library!

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## Why CQL is easy to implement

- Saving the world through CQL

- How do you decode CGI parameters?
- 	– use a library!
- How do you parse XML?
- 	– use a library!
- How do you send an HTTP request and get the response?
- 	– use a library!
- Now, who can guess how to parse CQL?

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## Why CQL is easy to implement (Java)

- Saving the world through CQL

- import org.z3950.zing.cql;
- CQLParser parser = new CQLParser();
- CQLNode root;
- try {
- 	root = parser.parse(cql);
- } catch (CQLParseException ex) {
- 	System.err.println("Syntax error: " + ex.getMessage());
- }

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## Super-easy!

- Why CQL is easy to implement (Java)

- Saving the world through CQL

- import org.z3950.zing.cql;
- CQLParser parser = new CQLParser();
- CQLNode root;
- try {
- 	root = parser.parse(cql);
- } catch (CQLParseException ex) {
- 	System.err.println("Syntax error: " + ex.getMessage());
- }

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## Why CQL is easy to implement (Perl)

- Saving the world through CQL

- use CQL::Parser;
- my $parser = new CQL::Parser();
- my $node;
- eval {
- 	$node = $parser->parse($query);
- }; if ($@) {
- 	die "CQL syntax error: $@";
- }

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## Embarrassingly

- Why CQL is easy to implement (Perl)

- Saving the world through CQL

- use CQL::Parser;
- my $parser = new CQL::Parser();
- my $node;
- eval {
- 	$node = $parser->parse($query);
- }; if ($@) {
- 	die "CQL syntax error: $@";
- }

- Trivial!

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## Why CQL is easy to implement (C)

- Saving the world through CQL

- #include <yaz/cql.h>
- CQL_parser cp = cql_parser_create();
- struct cql_node *root;
- r = cql_parser_string(cp, query);
- if (r) {
- 	fprintf(stderr, "Syntax error\n");
- } else {
- 	root = cql_parser_result(cp);
- }

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## A child of three

- Why CQL is easy to implement (C)

- Saving the world through CQL

- #include <yaz/cql.h>
- CQL_parser cp = cql_parser_create();
- struct cql_node *root;
- r = cql_parser_string(cp, query);
- if (r) {
- 	fprintf(stderr, "Syntax error\n");
- } else {
- 	root = cql_parser_result(cp);
- }

- could do it!

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## Why CQL is easy to implement (Intercal)

- Saving the world through CQL

-         DO (5) NEXT
-     (5) DO FORGET #1
-         PLEASE WRITE IN :1
-         DO .1 <- 'V-":1~'#32768c/#0'"c/#1'~#3
-         DO (1) NEXT
-         DO :1 <- "'V-":1~'#65535c/#0'"c/#65535'
-                 ~'#0c/#65535'"c/"'V-":1~'#0c/#65535'"
-                 c/#65535'~'#0c/#65535'"
-         DO :2 <- #1
-         PLEASE DO (4) NEXT
-     (4) DO FORGET #1
-         DO .1 <- "V-':1~:2'c/#1"~#3
-         DO :1 <- "'V-":1~'#65535c/#0'"c/":2~'#65535
-                 c/#0'"'~'#0c/#65535'"c/"'V-":1~'#0

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## So easy,

- Why CQL is easy to implement (Intercal)

- Saving the world through CQL

-         DO (5) NEXT
-     (5) DO FORGET #1
-         PLEASE WRITE IN :1
-         DO .1 <- 'V-":1~'#32768c/#0'"c/#1'~#3
-         DO (1) NEXT
-         DO :1 <- "'V-":1~'#65535c/#0'"c/#65535'
-                 ~'#0c/#65535'"c/"'V-":1~'#0c/#65535'"
-                 c/#65535'~'#0c/#65535'"
-         DO :2 <- #1
-         PLEASE DO (4) NEXT
-     (4) DO FORGET #1
-         DO .1 <- "V-':1~:2'c/#1"~#3
-         DO :1 <- "'V-":1~'#65535c/#0'"c/":2~'#65535
-                 c/#0'"'~'#0c/#65535'"c/"'V-":1~'#0

- it hurts!

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## Now what?

- Saving the world through CQL

- Once you've got your CQL parse tree ...
- Walk the tree
- Convert it to your database's local query language
- If a CQL construct is unsupported, throw a diagnostic

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## Now what?

- Saving the world through CQL

- Once you've got your CQL parse tree ...
- Walk the tree
- Conv ert it to your database's local query language
- If a CQL construct is unsupported, throw a diagnostic
- It doesn't matter if you don't *implement* the whole language
- (No-one does that.)  The goal is:
- “if you can say it in your DB, you can say it in CQL.”

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## Boldly facing a bright new dawn

- Saving the world through CQL

- It really and truly is not that big a deal to implement CQL.

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## Boldly facing a bright new dawn

- Saving the world through CQL

- It really and truly is not that big a deal to implement CQL.
- Winners:
- Content providers: their databases get used

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## Boldly facing a bright new dawn

- Saving the world through CQL

- It really and truly is not that big a deal to implement CQL.
- Winners:
- Content providers: their databases get used
- Vendors: they can concentrate on the interesting problems

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## Boldly facing a bright new dawn

- Saving the world through CQL

- It really and truly is not that big a deal to implement CQL.
- Winners:
- Content providers: their databases get used
- Vendors: they can concentrate on the interesting problems
- Libraries: they don't need expensive metasearch solutions

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## Boldly facing a bright new dawn

- Saving the world through CQL

- It really and truly is not that big a deal to implement CQL.
- Winners:
- Content providers: their databases get used
- Vendors: they can concentrate on the interesting problems
- Libraries: they don't need expensive metasearch solutions
- Users: they find more good stuff!

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## Boldly facing a bright new dawn

- Saving the world through CQL

- It really and truly is not that big a deal to implement CQL.
- Winners:
- Content providers: their databases get used
- Vendors: they can concentrate on the interesting problems
- Libraries: they don't need expensive metasearch solutions
- Users: they find more good stuff!
- Losers:
- No-one!

**Notes:**
Free-form introduction to what challenges metasearching is meant to address, like:

## Saving the world through

- the wonder that is
- >>> ***CQL*** <<<
- Mike Taylor <_[mike@indexdata.com](mailto:mike@indexdata.com)_>
- Index Data – _[http://www.indexdata.com](http://www.indexdata.com/)_
- With a little help from BMNH R5937 “The Archbishop”, an as-yet undescribed brachiosaurid sauropod from the Upper Jurassic of the Tendaguru formation, Tanzania, Africa.