NAME
Search::Query::Parser - convert query strings into query objects
SYNOPSIS
use Search::Query;
my $parser = Search::Query->parser(
term_regex => qr/[^\s()]+/,
field_regex => qr/\w+/,
op_regex => qr/==|<=|>=|!=|=~|!~|[:=<>~#]/,
# ops that admit an empty left operand
op_nofield_regex => qr/=~|!~|[~:#]/,
# case insensitive
and_regex => qr/AND|ET|UND|E/i,
or_regex => qr/OR|OU|ODER|O/i,
not_regex => qr/NOT|PAS|NICHT|NON/i,
default_field => "",
phrase_delim => q/"/,
default_boolop => '+',
query_class => 'Search::Query::Dialect::Native',
field_class => 'Search::Query::Field',
);
my $query = $parser->parse('+hello -world now');
print $query;
DESCRIPTION
Search::Query::Parser is a fork of Search::QueryParser that supports multiple query dialects.
new
The following attributes may be initialized in new(). These are also available as get/set methods on the returned Parser object.
- default_boolop
- term_regex
- field_regex
- op_regex
- op_nofield_regex
- and_regex
- or_regex
- not_regex
- default_field
- fields
- phrase_delim
- query_class
- field_class
- clause_class
init
Overrides the base method to initialize the object.
fields
Returns the fields structure set by set_fields().
set_fields( fields )
Set the fields structure. Called internally by init() if you pass a fields
key/value pair to new().
parse( string )
Returns a Search::Query::Dialect object of type query_class.
If there is a syntax error in string, parse() will return undef
and set error().
error
Returns the last error message.
AUTHOR
Peter Karman, <karman at cpan.org>
BUGS
Please report any bugs or feature requests to bug-search-query at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Search-Query. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Search::Query
You can also look for information at:
RT: CPAN's request tracker
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
ACKNOWLEDGEMENTS
This module started as a fork of Search::QueryParser by Laurent Dami.
COPYRIGHT & LICENSE
Copyright 2010 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 http://dev.perl.org/licenses/ for more information.