NAME
Apache::Wyrd::Services::SearchParser - Object for performing logical word-searches
SYNOPSIS
use Apache::Wyrd::Services::SearchParser;
sub key {'key'};
sub search {
.....
}
my $parser = Apache::Wyrd::Services::SearchParser->new($self);
return $parser->parse('(search AND word) OR (web NOT page)');
DESCRIPTION
Allows for logical parsing of a search using AND, OR, NOT and DIFF keywords. Note that these keywords MUST be in upper-case to parse, otherwise they will be interpreted as the literal words.
Any search object using the parser should implement a search()
method which does a word search against a reverse-key index, returning an array of hashes.
Designed to work with Apache::Wyrd::Services::Index
, but can work with another search object as long as the search object returns arrays of hash items with unique IDs under the ID hash key. This ID hash key defaults to 'id', which is the default key for an Apache::Wyrd::Services::Index object. If your object uses a different ID key, it should return the (scalar) name of this ID key when it's key()
method is called.
METHODS
(format: (returns) name (arguments after self))
- (Apache::Wyrd::Services::SearchParser)
new
(objectref) -
Create a new parser object. The search object using the parser should pass a reference to itself as the argument, as
parse
will call it'ssearch
andkey
methods. - (array)
parse
(scalar, array) -
Parse accepts a phrase to parse for searching and an array which it will transparently pass to the
search
method of the calling object. Returns an array of results derived from recursively callingsearch
and joining the results based on the logical operators.
BUGS/CAVEATS/RESERVED METHODS
UNKNOWN
AUTHOR
Barry King <wyrd@nospam.wyrdwright.com>
SEE ALSO
LICENSE
Copyright 2002-2007 Wyrdwright, Inc. and licensed under the GNU GPL.
See LICENSE under the documentation for Apache::Wyrd
.