Lucy::...afQuery(3pm)

πŸ“¦
version 0.6.2 Β· 2 versions
, in fedora 43

πŸ’– 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 by perl v5.42.0 on 2025-07-25, straight from the User Contributed Perl Documentation collection. love u, go transform your leaves bestie πŸ’–βœ¨πŸŒΈ
πŸ“¦ where this page comes from