Lucy::...afQuery(3pm)
π NAME π
Lucy::Search::LeafQuery β bestie, it's the leaf node in a tree created by QueryParser. That's it, that's the vibe πΈ
Oh and hey, welcome to the User Contributed Perl Documentation corner of the internet, we're so happy you're here π«Ά
β¨ SYNOPSIS β¨
Not me showing you the whole vibe before we even get to the lore:
package MyQueryParser;
use base qw( Lucy::Search::QueryParser );
sub expand_leaf {
my ( $self, $leaf_query ) = @_;
if ( $leaf_query->get_text =~ /.\*\s*$/ ) {
return PrefixQuery->new(
query_string => $leaf_query->get_text,
field => $leaf_query->get_field,
);
}
else {
return $self->SUPER::expand_leaf($leaf_query);
}
}
See? Iconic. You're subclassing, you're overriding expand_leaf, you're checking get_text against /.\*\s*$/ and handing back a PrefixQuery with query_string and field, otherwise you're deferring to $self->SUPER::expand_leaf($leaf_query). Periodt π
π¦ DESCRIPTION π¦
Okay so here's the tea β LeafQuery objects are the leaf nodes in that tree structure that QueryParser's tree() method builds. They're like the little baby leaves at the end of every branch, so cute, so delicate π
But listen β they're not here to stay. They must be transformed, and like, typically into either TermQuery or PhraseQuery objects, because...
π¨ if you try to actually search a LeafQuery, it throws an error. No searching. Not allowed. Don't do it. It's giving "placeholder until you get your act together," fr fr π
π CONSTRUCTORS π
π new
my $leaf_query = Lucy::Search::LeafQuery->new(
text => '"three blind mice"', # required
field => 'content', # default: undef
);
Make yourself a brand new LeafQuery, bestie. Slay β¨
fieldβ Optional field name. Just chillin', optional.textβ Raw query text. Like, the actual words. Raw. Unfiltered. Main character energy π
π METHODS π
πΈ get_field
my $string = $leaf_query->get_field();
Accessor for the object's "field" attribute. Just hands you that field string, no drama π«Ά
π get_text
my $string = $leaf_query->get_text();
Accessor for the object's "text" attribute. Gimme the text, queen π
π make_compiler
my $compiler = $leaf_query->make_compiler(
searcher => $searcher, # required
boost => $boost, # required
subordinate => $subordinate, # default: false
);
Throws an error. That's the whole thing. That's the method. It literally just throws an error π
Not a compiler. Not today. Not ever. searcher and boost are required and subordinate defaults to false, but honestly? Doesn't matter, because it throws an error. The audacity. We stan a consistent queen π
π INHERITANCE π
The family tree goes like this:
Lucy::Search::LeafQuery isa Lucy::Search::Query isa Clownfish::Obj.
Three generations of iconic. It's in the blood, iykyk π§
β and that's the whole page, no cap! brought to you byperl v5.42.0on2025-07-25, straight from the User Contributed Perl Documentation collection. love u, go transform your leaves bestie πβ¨πΈ
π¦ 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