1Lucy::Search::LeafQueryU(s3e)r Contributed Perl DocumentaLtuicoyn::Search::LeafQuery(3)
2
3
4
6 Lucy::Search::LeafQuery - Leaf node in a tree created by QueryParser.
7
9 package MyQueryParser;
10 use base qw( Lucy::Search::QueryParser );
11
12 sub expand_leaf {
13 my ( $self, $leaf_query ) = @_;
14 if ( $leaf_query->get_text =~ /.\*\s*$/ ) {
15 return PrefixQuery->new(
16 query_string => $leaf_query->get_text,
17 field => $leaf_query->get_field,
18 );
19 }
20 else {
21 return $self->SUPER::expand_leaf($leaf_query);
22 }
23 }
24
26 LeafQuery objects serve as leaf nodes in the tree structure generated
27 by QueryParserXs tree() method. Ultimately, they must be transformed,
28 typically into either TermQuery or PhraseQuery objects, as attempting
29 to search a LeafQuery causes an error.
30
32 new
33 my $leaf_query = Lucy::Search::LeafQuery->new(
34 text => '"three blind mice"', # required
35 field => 'content', # default: undef
36 );
37
38 Create a new LeafQuery.
39
40 · field - Optional field name.
41
42 · text - Raw query text.
43
45 get_field
46 my $string = $leaf_query->get_field();
47
48 Accessor for objectXs "field" attribute.
49
50 get_text
51 my $string = $leaf_query->get_text();
52
53 Accessor for objectXs "text" attribute.
54
55 make_compiler
56 my $compiler = $leaf_query->make_compiler(
57 searcher => $searcher, # required
58 boost => $boost, # required
59 subordinate => $subordinate, # default: false
60 );
61
62 Throws an error.
63
65 Lucy::Search::LeafQuery isa Lucy::Search::Query isa Clownfish::Obj.
66
67
68
69perl v5.32.0 2020-07-28 Lucy::Search::LeafQuery(3)