List Info

Thread: Re: Using QueryFilter and BooleanQuery




Re: Using QueryFilter and BooleanQuery
country flaguser name
United States
2008-04-16 09:34:05
One bug in your script is your indexing into ARGV.
$ARGV[0] is not the first parameter to the script, it's the
script filename itself. Try this:

print join (', ', ARGV) . "n";


----- Original Message ----
> From: Riyaad Miller <riyaad.millerpredix.com>
> To: kinosearchrectangular.com
> Sent: Wednesday, April 16, 2008 9:49:33 AM
> Subject: [KinoSearch] Using QueryFilter and
BooleanQuery
> 
> Hi guys
> 
> Thanks for your previous reply.
> 
> I've installed KinoSearch ver. 0.162. Could you please
confirm the QueryFilter 
> is NOT available in this release (0.162)?
> 
> With regards to BooleanQuery, I've put together the
following command line 
> script using ver. 0.162.
>  
> When entering 'perl' as my first arg and nutshell as my
second (my code should 
> exclude results contain 'nutshell') 
> but for some strange reason it still returns the
results with 'nutshell' in 
> them. Could you please tell me what am I doing wrong
here?
> 
> Appreciated.
> 
> 
> -----------------------------------------
> 
> use KinoSearch::Searcher;
> use KinoSearch::Analysis::PolyAnalyzer;
> use KinoSearch::Highlight::Highlighter;
> use KinoSearch::Search::QueryFilter;
> use KinoSearch::Search::BooleanQuery;
> 
> $incl = $ARGV[0];
> $incl = '' unless defined $incl;
> 
> $excl = $ARGV[1];
> $excl = '' unless defined $excl;
> 
> print "find $incl but exclude $excln";
> 
> print "." x 80 . "n";
> 
> $invIndexDirectory = '/tmp/KinoSearchIndex';
> 
> $analyzer =
KinoSearch::Analysis::PolyAnalyzer->new(language =>
'en');
> 
> $searcher = KinoSearch::Searcher->new(
>  analyzer => $analyzer,
>  invindex => $invIndexDirectory
> );
> 
> $bool_query =
KinoSearch::Search::BooleanQuery->new;
> 
> $include  = KinoSearch::Search::TermQuery->new(term
=> 
> KinoSearch::Index::Term->new('bodytext',$incl));
> $bool_query->add_clause(query => $include,
occur=>'MUST');
> $exclude  = KinoSearch::Search::TermQuery->new(term
=> 
> KinoSearch::Index::Term->new('bodytext',$excl));
> $bool_query->add_clause(query => $exclude,
occur=>'MUST_NOT');
> 
> $hits = $searcher->search(
>   query  => $bool_query,
> );
> 
> $highlighter =
KinoSearch::Highlight::Highlighter->new(excerpt_field
=> 
> 'bodytext');
> $hits->create_excerpts(highlighter =>
$highlighter);
> 
> print "-" x 80 . "n";
> 
> while ($hit = $hits->fetch_hit_hashref)
> {
>   print  "Title: $hit->n";
>   print  "URL  : $hit->n";
>   print  "Exc  : $hit->n";
>   printf "Score: %0.3fn", $hit->;
>   print "-" x 80 . "n";
> }
> 
> 
> -------End-------
> 
> 
> _______________________________________________
> KinoSearch mailing list
> KinoSearchrectangular.com
> http://www.rectangular.com/mailman/listinfo/kinosearch

> 




     
____________________________________________________________
________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9
tAcJ


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


Re: Using QueryFilter and BooleanQuery
country flaguser name
Italy
2008-04-16 09:44:35
On 16-04-2008 at 16:34, jack_tanneryahoo.com wrote:

 >One bug in your script is your indexing into ARGV.
$ARGV[0] is not
 >the first parameter to the script, it's the script
filename itself.
 >Try this:
 >print join (', ', ARGV) . "n";

You're confusing Perl with C. See perlvar:

ARGV
  The array ARGV contains the command-line arguments intended
       for the script.  $#ARGV is generally the number of
arguments
       minus one, because $ARGV[0] is the first argument,
not the pro-
       gram's command name itself.  See $0 for the command
name.
       
al.

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


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )