Mailing List Archive

leaky filters
Using the development version of KinoSearch (0.20) I'm trying to filter
the query results by a range filter (date) and two optional query
filters (agency and docType). The range filter works great. The query
filters seem to have no effect at all. I'm probably missing something
obvious here, but I just can't see what I'm doing wrong. Any help would
be appreciated

-- JP

Here's the relevant code:

my $general_query = $query_parser->parse( $query_string );

my $agency_filter;
if ( $agency ) {
my $agency_query = KinoSearch::Search::TermQuery->new(
term => KinoSearch::Index::Term->new( 'source', $agency ),
);

$agency_filter = KinoSearch::Search::QueryFilter->new(
query => $agency_query,
);
}

my $docType_filter;
if ( $doctype ) {
my $docType_query = KinoSearch::Search::TermQuery->new(
term => KinoSearch::Index::Term->new( 'docType', 'audit' ),
);

$docType_filter = KinoSearch::Search::QueryFilter->new(
query => $docType_query,
);
}

my $from_date = $from || '2003-05-01';
my $to_date = $to || '2007-09-01';
my $date_filter = KinoSearch::Search::RangeFilter->new(
field => 'date',
lower_term => $from_date,
upper_term => $to_date,
include_lower => 1,
include_upper => 1,
);

my $filters = KinoSearch::Search::PolyFilter->new;
$filters->add( filter => $date_filter );
$filters->add( filter => $agency_filter, logic => 'AND' ) if
$agency_filter;
$filters->add( filter => $docType_filter, logic => 'AND' ) if
$docType_filter;


my $hits = $searcher->search( query => $general_query, filter =>
$filters, );


_______________________________________________
KinoSearch mailing list
KinoSearch@rectangular.com
http://www.rectangular.com/mailman/listinfo/kinosearch
Re: leaky filters [ In reply to ]
On Sep 5, 2007, at 9:59 AM, John Perry wrote:

> Using the development version of KinoSearch (0.20) I'm trying to
> filter the query results by a range filter (date) and two optional
> query filters (agency and docType). The range filter works great.
> The query filters seem to have no effect at all. I'm probably
> missing something obvious here, but I just can't see what I'm doing
> wrong.

What analyzer is being used on the agency and docType fields?
Keyword fields like docType ususally should not be analyzed.
My guess is that you have a stemmed/non-stemmed mismatch...

> my $agency_query = KinoSearch::Search::TermQuery->new(
> term => KinoSearch::Index::Term->new( 'source', $agency ),
> );
> $agency_filter = KinoSearch::Search::QueryFilter->new(
> query => $agency_query,
> );
> }
>
> my $docType_filter;
> if ( $doctype ) {
> my $docType_query = KinoSearch::Search::TermQuery->new(
> term => KinoSearch::Index::Term->new( 'docType', 'audit' ),
> );
> $docType_filter = KinoSearch::Search::QueryFilter->new(
> query => $docType_query,
> );
> }

... at least on the agency field. On the docType field, should that
"'audit'" be hard coded?

Marvin Humphrey
Rectangular Research
http://www.rectangular.com/



_______________________________________________
KinoSearch mailing list
KinoSearch@rectangular.com
http://www.rectangular.com/mailman/listinfo/kinosearch
Re: leaky filters [ In reply to ]
That was it. I switched the fields to unanalyzed and it worked like a
charm. I knew I was missing something something stupid and obvious. (And
also the hard-coded 'audit' ... d'oh)

Thanks for your help

-- JP

>On Sep 5, 2007, at 9:59 AM, John Perry wrote:
>
>> Using the development version of KinoSearch (0.20) I'm trying to
>> filter the query results by a range filter (date) and two optional
>> query filters (agency and docType). The range filter works great.
>> The query filters seem to have no effect at all. I'm probably
>> missing something obvious here, but I just can't see what I'm doing
>> wrong.
>
>What analyzer is being used on the agency and docType fields?
>Keyword fields like docType ususally should not be analyzed.
> My guess is that you have a stemmed/non-stemmed mismatch...
>
>> my $agency_query = KinoSearch::Search::TermQuery->new(
>> term => KinoSearch::Index::Term->new( 'source', $agency ),
>> );
>> $agency_filter = KinoSearch::Search::QueryFilter->new(
>> query => $agency_query,
>> );
>> }
>>
>> my $docType_filter;
>> if ( $doctype ) {
>> my $docType_query = KinoSearch::Search::TermQuery->new(
>> term => KinoSearch::Index::Term->new( 'docType', 'audit' ),
>> );
>> $docType_filter = KinoSearch::Search::QueryFilter->new(
>> query => $docType_query,
>> );
>> }
>
>... at least on the agency field. On the docType field, should that
>"'audit'" be hard coded?
>
>Marvin Humphrey
>Rectangular Research
>http://www.rectangular.com/



_______________________________________________
KinoSearch mailing list
KinoSearch@rectangular.com
http://www.rectangular.com/mailman/listinfo/kinosearch