Plucen...anQuery(3pm)
π Plucene::Search::BooleanQuery β a boolean query π
okay bestie, pull up a chair, we're looking at Plucene::Search::BooleanQuery from the User Contributed Perl Documentation collection (yes, the (3pm) girlies know what's up) and honestly? she's iconic. let's get into it π«Ά
β¨ SYNOPSIS β¨
# isa Plucene::Search::Query
$query->add(Plucene::Search::Query $query, $required, $prohibited);
$query->normalize($norm);
my @clauses = $query->clauses;
my $sum_sq_weights = $query->sum_squared_weights($searcher);
my $as_string = $query->to_string($field);
look at her go π
πΈ DESCRIPTION πΈ
So. This is a query that matches documents matching boolean combinations of other queries β typically TermQuerys or PhraseQuerys. no cap.
A boolean query is basically a composite query, meaning it can hold subqueries with arbitrary nesting level, and those subqueries get glued together with composition rules like 'and', 'or', or 'not'. it's giving β¨main character energyβ¨ but for queries.
In the Plucene API, boolean queries show up as instances of the BooleanQuery class. Every BooleanQuery object holds a list of subqueries, and those subqueries are linked together using instances of the adaptor class BooleanClause. The subqueries can be any Query type β term query, phrase query, nested boolean queries, literally whatever. π₯
Every subquery inside a boolean query carries two binary qualifiers that control how its super query gets matched. These qualifiers are:
- prohibited β when this flag is set, the matching status of the subquery gets negated, so the query only counts as a match when the subquery does not match. π
- required β when this flag is set, the subquery has to match (or has to not match, if its
'prohibited'flag is set) for the super query to match. This is a necessary but not sufficient condition for the super query to match. periodt.
π METHODS π
π¦ add π¦
$query->add(Plucene::Search::Query $query, $required, $prohibited);
Adds a clause to a boolean query. Clauses can be:
- required β which means documents that do not match this sub-query will not match the boolean query;
- prohibited β which means documents that do match this sub-query will not match the boolean query; or
- neither! in which case matched documents are neither prohibited from nor required to match the sub-query. it's giving "no thoughts, just vibes" π
bestie listen: it is an error to specify a clause as bothrequiredandprohibited. pick a lane. π
π add_clause π
$self->add_clause(Plucene::Search::BooleanClause $c);
Adds an already-formed clause onto the query. like, she's pre-made, you're just sliding her in π
β clauses β
my @clauses = $query->clauses;
π§ sum_squared_weights π§
my $sum_sq_weights = $query->sum_squared_weights($searcher);
π normalize π
$query->normalize($norm);
β¨ to_string β¨
my $as_string = $query->to_string($field);
π POD ERRORS π
Hey! The above document had some coding errors, which are explained below:
- Around line 83:
- Expected text after
=item, not a bullet
- Expected text after
(not the doc being messy π we still love her though)
perl v5.36.0 Β· 2022-12-04 Β· Plucen...anQuery(3pm)
and that's the whole page bestie π«Ά go forth, build your boolean queries, and remember: required and prohibited are not a couple, they do NOT go together. slay πβ¨π
π¦ where this page comes from
- debian bookworm: libplucene-perl 1.25-5
- debian trixie: libplucene-perl 1.25-5
- ubuntu noble: libplucene-perl 1.25-5
- ubuntu resolute: libplucene-perl 1.25-5
- ubuntu stonking: libplucene-perl 1.25-5
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms