Plucen...anQuery(3pm)

πŸ“¦
version 1.25 Β· 2 versions
  • 1.25 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 1.25 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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 both required and prohibited. 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

(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