KinoSe...yParser(3pm)

πŸ’– KinoSearch1::QueryParser::QueryParser πŸ’–

okay bestie, gather round, because this one is literally the glow-up station for your search strings πŸ’… in the KinoSearch1 family of Perl modules (you know, the ones in User Contributed Perl Documentation). It takes a plain lil string and turns it into a whole Query object. iconic behavior, no cap ✨


✨ NAME ✨

KinoSearch1::QueryParser::QueryParser β€” the thing that transforms a string into a Query object πŸ¦‹


🌸 SYNOPSIS 🌸

my $query_parser = KinoSearch1::QueryParser::QueryParser->new(
    analyzer => $analyzer,
    fields   => [ 'bodytext' ],
);
my $query = $query_parser->parse( $query_string );
my $hits  = $searcher->search( query => $query );

πŸŽ€ DESCRIPTION πŸŽ€

So basically: QueryParser takes search strings as input, and it hands you back Query objects. Those are exactly the kind of objects you feed straight into KinoSearch1::Searcher. match made in heaven fr fr 🫢

πŸ”₯ Syntax πŸ”₯

Here's the tea β€” these are the constructs QueryParser actually recognizes:

  • Boolean operators 'AND', 'OR', and 'AND NOT' πŸ‘‘
  • A +plus or -minus stuck on the front, which means the labeled entity is either required or forbidden. And by "entity" I mean literally anything β€” a single word, a phrase, a whole parenthetical group, all of it. she's flexible like that πŸ’…
  • Logical groups, living inside parentheses.
  • Phrases, wrapped in double quotes.
  • Field-specific terms, shaped like "fieldname:termtext". (When you do this, the field you named in fieldname gets used instead of the QueryParser's default fields. very demure, very mindful.)

And plot twist β€” you can give a field to a logical group too! It works out to the exact same thing as prepending that field onto every single term in the group. For example: "foo:(bar baz)" is the same as "foo:bar foo:baz". periodt πŸ’–


πŸ’œ METHODS πŸ’œ

🌈 new

my $query_parser = KinoSearch1::QueryParser::QueryParser->new(
    analyzer       => $analyzer,       # required
    fields         => [ 'bodytext' ],  # required
    default_boolop => 'AND',           # default: 'OR'
);

Constructor, babes. It takes hash-style parameters:

  • analyzer β€” an object that subclasses KinoSearch1::Analysis::Analyzer. 🚨 listen: this has to be identical to the Analyzer you used at index-time, otherwise your results will not match up. not even a little. pls do not play with this one 😭
  • fields β€” the names of the fields that are gonna get searched against. Must be supplied as an arrayref, okay? Not a plain list, an arrayref. 🌸
  • default_field β€” deprecated. Use "fields" instead. she's retired, let her rest πŸ’€
  • default_boolop β€” two possible values: 'AND' and 'OR'. The default is 'OR', which means: return documents that match any of the query terms. If you only want documents that match all of the query terms, set this to 'AND'. choose your fighter ⭐

πŸ¦‹ parse

my $query = $query_parser->parse( $query_string );

Turn a query string into a Query object. And depending on what's inside that query string, the returned object could be any one of several subclasses of KinoSearch1::Search::Query. surprise! main character energy, you never know who's gonna show up πŸŽ€


Copyright 2005-2010 Marvin Humphrey


πŸ’€ LICENSE, DISCLAIMER, BUGS, etc. πŸ’€

See KinoSearch1 version 1.01.


okay that's the whole page, you ate it πŸ’… and just so you have the receipts: this was the KinoSearch1::QueryParser::QueryParser page from perl v5.42.3, dated 2026-08-20, filed under User Contributed Perl Documentation. go forth and parse, bestie πŸ§šπŸ’–βœ¨

πŸ“¦ where this page comes from