Peter Karman > SWISH-Prog-Lucy-0.17 > SWISH::Prog::Lucy::Searcher



Annotate this POD



Open  0
View/Report Bugs
Module Version: 0.17   Source   Latest Release: SWISH-Prog-Lucy-0.25


SWISH::Prog::Lucy::Searcher - search Swish3 Lucy backend


 my $searcher = SWISH::Prog::Lucy::Searcher->new(
     invindex             => 'path/to/index',
     max_hits             => 1000,
     find_relevant_fields => 1,   # default: 0
     nfs_mode             => 1,   # default: 0
 my $results = $searcher->search( 'foo bar' );
 while (my $result = $results->next) {
     printf("%4d %s\n", $result->score, $result->uri);


SWISH::Prog::Lucy::Searcher is an Apache Lucy based Searcher class for Swish3.

SWISH::Prog::Lucy::Searcher is not made to replace the more fully-featured Lucy::Search::Searcher class and its friends. Instead, SWISH::Prog::Lucy::Searcher provides a simple API similar to other SWISH::Prog::Searcher-based backends so that you can experiment with alternate storage engines without needing to change much code. When your search application requirements become more complex, the author recommends the switch to using Lucy::Search::Searcher directly.


Only new and overridden methods are documented here. See the SWISH::Prog::Searcher documentation.


Called internally by new(). Additional parameters include:

find_relevant_fields 1|0

Set to true to have the Results object locate the fields that matched the query. Default is 0 (off).

qp search_query_parser_object

Optional. If passed, should be a Search::Query::Parser object. You can get/set the internal parser with the qp() method as well.

qp_config hash_ref

Optional. If set, the internal Search::Query::Parser object will be initialized with hash_ref.

nfs_mode 1|0

Set to true if your index is stored on a NFS filesystem. Extra locking precautions are implemented when this mode is on (1). Default is off (0).


Returns array ref of PropertyNames defined for the invindex. The array will not contain any alias names or reserved PropertyNames.

search( query [, opts ] )

Returns a SWISH::Prog::Lucy::Results object.

query is assumed to be query string compatible with Search::Query::Dialect::Lucy.

opts is an optional hashref with the following supported key/values:


The starting position. Default is 0.


The ending position. Default is max_hits() as documented in SWISH::Prog::Searcher.


Takes a SQL-like text string (like SWISH::Prog::Native::Searcher) or a Lucy::Search::SortSpec object, which will determine the sort order.


Takes an arrayref of arrayrefs. Each child arrayref should have three values: a field (PropertyName) value, a lower limit and an upper limit.


The default boolean connector for parsing query. Valid values are AND and OR. The default is AND (which is different than Lucy::QueryParser, but the same as Swish-e).


Returns the internal Lucy::Search::PolySearcher object.


Peter Karman, <karman at>


Please report any bugs or feature requests to bug-swish-prog-lucy at, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


You can find documentation for this module with the perldoc command.

    perldoc SWISH::Prog::Lucy

You can also look for information at:


Copyright 2009 Peter Karman.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See for more information.

syntax highlighting: