Search::QueryBuilder - Perl extension for tokenising search strings and building queries
use Search::QueryBuilder; my $querybuild=new QueryBuilder; # $querystring contains a query along the lines of "A key phrase" -"keyword" AND keyword +keyword my @responsearr=$querybuild->getTokenizedString($querystring); # @responsearr contains the keywords and phrases, plus booleans where provided If you intend to use more than the basic booleans, add them as follows: my @mytaglist=("AND","OR","NOT","XOR"); $querybuild->tags(@mytaglist);
QueryBuilder is a very simple tokeniser, designed to decode a query string into something you can create a database query from (into SQL, Cheshire, that sort of thing).
It tries to do a little sanity checking, but is still in active development so expect changes. The creation of queries from the resulting string is partly merged into the module, but expect this interface to change.
None by default.
There are actually several other modules out there that are related - for example, String::Tokeniser, String::Tokenizer, Parse::Tokens and Text::Tokenizer.
This one is designed specifically for use as part of a search system, and is likely to evolve in that direction (handling of prefixes, building up search queries in various formats and so forth).
Other approaches to this include Search::Circa and Search::QueryParser.
E Tonkin, <cselt@users.sourceforge.net<gt>
Copyright (C) 2006 by E Tonkin
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.7 or, at your option, any later version of Perl 5 you may have available.
To install Search::QueryBuilder, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Search::QueryBuilder
CPAN shell
perl -MCPAN -e shell install Search::QueryBuilder
For more information on module installation, please visit the detailed CPAN module installation guide.