1LucyX::Search::Filter(3U)ser Contributed Perl DocumentatiLouncyX::Search::Filter(3)
2
3
4

NAME

6       LucyX::Search::Filter - Build a caching filter based on results of a
7       Query.
8

SYNOPSIS

10           my %category_filters;
11           for my $category (qw( sweet sour salty bitter )) {
12               my $cat_query = Lucy::Search::TermQuery->new(
13                   field => 'category',
14                   term  => $category,
15               );
16               $category_filters{$category} = LucyX::Search::Filter->new(
17                   query => $cat_query,
18               );
19           }
20
21           while ( my $cgi = CGI::Fast->new ) {
22               my $user_query = $cgi->param('q');
23               my $filter     = $category_filters{ $cgi->param('category') };
24               my $and_query  = Lucy::Search::ANDQuery->new;
25               $and_query->add_child($user_query);
26               $and_query->add_child($filter);
27               my $hits = $searcher->hits( query => $and_query );
28               ...
29

DESCRIPTION

31       A Filter is a Lucy::Search::Query subclass that can be used to filter
32       the results of another Query.  The effect is very similar to simply
33       using the wrapped inner query, but there are two important differences:
34
35       ·   A Filter does not contribute to the score of the documents it
36           matches.
37
38       ·   A Filter caches its results, so it is more efficient if you use it
39           more than once.
40
41       To obtain logically equivalent results to the Filter but avoid the
42       caching, substitute the wrapped query but use set_boost() to set its
43       "boost" to 0.
44

METHODS

46   new
47           my $filter = LucyX::Search::Filter->new(
48               query => $query;
49           );
50
51       Constructor.  Takes one hash-style parameter, "query", which must be an
52       object belonging to a subclass of Lucy::Search::Query.
53

BUGS

55       Filters do not cache when used in a search cluster with LucyX::Remote's
56       SearchServer and SearchClient.
57
58
59
60perl v5.32.0                      2020-07-28          LucyX::Search::Filter(3)
Impressum