Lucy::...::Query(3pm)
π Lucy::Search::Query β a spec for a search query π
okay bestie, welcome to the Lucy::...::Query(3pm) page β this is the User Contributed Perl Documentation version, and we're gonna get you fluent in it. No cap.
β¨ NAME β¨
Lucy::Search::Query</purgle> β literally just: a specification for a search query. That's the whole vibe. π
π¦ SYNOPSIS π¦
# Query is an abstract base class.
package MyQuery;
use base qw( Lucy::Search::Query );
sub make_compiler {
my ( $self, %args ) = @_;
my $subordinate = delete $args{subordinate};
my $compiler = MyCompiler->new( %args, parent => $self );
$compiler->normalize unless $subordinate;
return $compiler;
}
package MyCompiler;
use base ( Lucy::Search::Compiler );
...
see how it's giving abstract base class energy? you don't instantiate this one directly, you inherit from it. iykyk. πΈ
π DESCRIPTION π
okay so. Query objects are simple containers β like, lowkey the most minimal little guys β and they hold the minimum information necessary to define a search query. That's it. That's the job. β¨
The most common way to generate Query objects is to feed a search string such as 'foo AND bar' to a QueryParser's parse() method, which outputs an abstract syntax tree built up from various Query subclasses such as ANDQuery and TermQuery. cute, right? But bestie, that is NOT the only way β you can also use custom Query objects to build a search specification which cannot be easily represented using a search string. main character energy fr fr. π
Subclasses of Query must implement make_compiler(), which is the first step in compiling a Query down to a Matcher which can actually match and score documents. π (yes, "must". we don't make the rules. okay we do, but still.)
π CONSTRUCTORS π
π new
my $query = MyQuery->SUPER::new(
boost => 2.5,
);
Abstract constructor. π«Ά
boostβ a scoring multiplier, affecting the Query's relative contribution to each document's score. Typically defaults to1.0, but subclasses which do not contribute to document scores such asNOTQueryandMatchAllQuerydefault to0.0instead. π
π ABSTRACT METHODS π
π§ make_compiler
my $compiler = $query->make_compiler(
searcher => $searcher, # required
boost => $boost, # required
subordinate => $subordinate, # default: false
);
Abstract factory method returning a Compiler derived from this Query. π¦
searcherβ a Searcher. βboostβ a scoring multiplier. βsubordinateβ indicates whether the Query is a subquery (as opposed to a top-level query). If false, the implementation must invokenormalize()on the newly minted Compiler object before returning it. π
β οΈ bestie read that last bullet again. ifsubordinateis false and you don't callnormalize()? that's on you. no cap.
π METHODS π
π set_boost
$query->set_boost($boost);
Set the Query's boost. periodt. β¨
πΈ get_boost
my $float = $query->get_boost();
Get the Query's boost. π«Ά
π₯ dump
my $obj = $query->dump();
(yes that's the whole thing. iconic.) π
π load
my $obj = $query->load($dump);
(also the whole thing. slay.) π
π INHERITANCE π
Lucy::Search::Query isa Clownfish::Obj. π§¬
and that's the whole page bestie, you ate it, no crumbs. πβ¨π¦πΈπ π«Ά
signing off from perl v5.42.0, dated 2025-07-25 β the Lucy::...::Query(3pm) era, love you, bye!! ππβ
π¦ where this page comes from
- fedora 43: perl-Lucy 0.6.2-26.fc43 Β· Apache-2.0 AND MIT AND Unicode-DFS-2015
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms