Search::Tools::Query - objectified string for highlighting, snipping, etc.
use Search::Tools::QueryParser; my $qparser = Search::Tools::QueryParser->new; my $query = $qparser->parse(q(the quick color:brown "fox jumped")); my $fields = $query->fields; # ['color'] my $terms = $query->terms; # ['quick', 'brown', '"fox jumped"'] my $regex = $query->regex_for($terms->); # S::T::RegEx my $tree = $query->tree; # the Search::Query::Dialect tree() print "$query\n"; # the quick color:brown "fox jumped" print $query->str . "\n"; # same thing
Array ref of fields from the original query string. See Search::Tools::QueryParser for controls over ignore_fields().
Array ref of key words from the original query string. See Search::Tools::QueryParser for controls over ignore_fields() and tokenizing regex.
NOTE: Only positive words are extracted by QueryParser. In other words, if you search for:
foo not bar
foo is returned. Likewise:
would return only
The original string.
The hash ref of terms to Search::Tools::RegEx objects.
The internal Search::Query::Dialect object. See tree() and str_clean() which delegate to the dialect object.
The Search::Tools::QueryParser object used to generate the Query.
Returns the number of terms().
Returns array ref of unique terms from query. If stemming was on in the QueryParser, all terms have already been stemmed as part of the parsing process.
Returns number of unique_terms().
Return array ref of RegEx objects for all terms where is_phrase is true.
Return array ref of RegEx objects for all terms where is_phrase is false.
Returns the internal Search::Query::Dialect tree().
Returns the internal Search::Query::Dialect stringify().
Returns a Search::Tools::RegEx object for term.
Alias for regex_for(). The author has come to prefer "regex" instead of "regexp" because it's one less keystroke.
Returns the number of matches for the query against text.
Returns the number of matches for the query against html.
Returns all terms() as a single qr// regex, pipe-joined in a "OR" logic.
Please report any bugs or feature requests to
bug-search-tools at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Search-Tools. 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.
You can also look for information at:
Copyright 2009 by Peter Karman.
This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself.