Catman...DB::CQL(3pm)

πŸ’… NAME πŸ’…

Catmandu::Store::MongoDB::CQL β€” bestie, it takes a CQL query string and turns it into a MongoDB query string. That's it. That's the whole job. And it slays at it.


✨ SYNOPSIS ✨

$mongo_query = Catmandu::Store::ElasticSearch::CQL
                ->new(mapping => $cql_mapping)
                ->parse($cql_query_string);

okay so you build one with a mapping, then you parse your CQL string. Simple. Clean. Iconic. πŸŽ€


🌸 DESCRIPTION 🌸

ngl this package currently parses most of CQL 1.1, and the vibes are immaculate. Here's the full list of what it knows how to handle:

  • and
  • or
  • not
  • srw.allRecords
  • srw.serverChoice
  • srw.anywhere
  • cql.allRecords
  • cql.serverChoice
  • cql.anywhere
  • =
  • scr
  • <
  • >
  • <=
  • >=
  • <>
  • exact
  • all
  • any
  • within

if you want the full lore on the CQL query language itself, the source material lives at <https://www.loc.gov/standards/sru/cql/spec.html> πŸ’œ


πŸ’€ LIMITATIONS πŸ’€

okay bestie, real talk, this is the part where we need to sit down. MongoDB is not a full-text search engine. Not even close. So basically every query is gonna try to find exact matches in the database β€” with two exceptions, and those exceptions are any and all.

Those two relations get translated into wildcard queries, and wildcard queries are slow. Not "kinda slow." Slow slow.

So like, this:

title any 'funny cats'

gets treated internally as something like:

title : { $regex : /funny/ } OR title : { $regex : /cats/ }

And this:

title all 'funny cats'

becomes:

title : { $regex : /funny/ } AND title : { $regex : /cats/ }
🫢 so yeah β€” any and all are not as efficient (fast) as the exact matches == and exact. That's just the deal, no cap.

πŸ‘‘ METHODS πŸ‘‘

πŸ”₯ parse

Parses the given CQL query string with CQL::Parser and converts it to a Mongo query string. It literally just does what it says. ✨

πŸ¦‹ visit

Converts the given CQL::Node to a Mongo query string. Main character energy, tiny method.


πŸ™ˆ REMARKS πŸ™ˆ

  • no support for fuzzy search
  • no support for search modifiers
  • no support for sortBy
  • no support for encloses

we simply do not do those things here πŸ’…


⭐ SEE ALSO ⭐

CQL::Parser.


okay that's the whole page, ily, go parse something πŸ’–

this was Catman...DB::CQL(3pm) β€” part of the perl v5.32.1 era, dated 2021-09-02, living under User Contributed Perl Documentation. bye bestie, mwah πŸ˜˜πŸŽ€

πŸ“¦ where this page comes from