Marvin Humphrey > KinoSearch-0.30_04 > KSx::Search::Filter

Download:
KinoSearch-0.30_04.tar.gz

Annotate this POD

CPAN RT

Open  7
View Bugs
Report a bug
Source   Latest Release: KinoSearch-0.30_07

NAME ^

KSx::Search::Filter - Build a caching filter based on results of a Query.

SYNOPSIS ^

    my %category_filters;
    for my $category (qw( sweet sour salty bitter )) {
        my $cat_query = KinoSearch::Search::TermQuery->new(
            field => 'category',
            term  => $category,
        );
        $category_filters{$category} = KSx::Search::Filter->new( 
            query => $cat_query, 
        );
    }
    
    while ( my $cgi = CGI::Fast->new ) {
        my $user_query = $cgi->param('q');
        my $filter     = $category_filters{ $cgi->param('category') };
        my $and_query  = KinoSearch::Search::ANDQuery->new;
        $and_query->add_child($user_query);
        $and_query->add_child($filter);
        my $hits = $searcher->hits( query => $and_query );
        ...

DESCRIPTION ^

A Filter is a KinoSearch::Search::Query subclass that can be used to filter the results of another Query. The effect is very similar to simply using the wrapped inner query, but there are two important differences:

To obtain logically equivalent results to the Filter but avoid the caching, substitute the wrapped query but use set_boost() to set its boost to 0.

METHODS ^

new

    my $filter = KSx::Search::Filter->new(
        query => $query;
    );

Constructor. Takes one hash-style parameter, query, which must be an object belonging to a subclass of KinoSearch::Search::Query.

BUGS ^

Filters do not cache when used in a search cluster with KSx::Remote's SearchServer and SearchClient.

COPYRIGHT ^

Copyright 2005-2009 Marvin Humphrey

LICENSE, DISCLAIMER, etc. ^

See KinoSearch version 0.30.