Lucy::Search::Query - A specification for a search query.
# 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 ); ...
Query objects are simple containers which contain the minimum information necessary to define a search query.
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. However, it is also possible to use custom Query objects to build a search specification which cannot be easily represented using a search string.
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.
my $query = MyQuery->SUPER::new( boost => 2.5, );
Abstract constructor.
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.
$query->set_boost($boost);
Set the Query’s boost.
my $float = $query->get_boost();
Get the Query’s boost.
my $obj = $query->dump();
my $obj = $query->load($dump);
Lucy::Search::Query isa Clownfish::Obj.
Copyright © 2010-2015 The Apache Software Foundation, Licensed under the
Apache License, Version 2.0.
Apache Lucy, Lucy, Apache, the Apache feather logo, and the Apache Lucy project logo are trademarks of The
Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their
respective owners.