Search::Tools::Query - objectified string for highlighting, snipping, etc.


Search-Tools documentation  | view source Contained in the Search-Tools distribution.

Index


NAME

Top

Search::Tools::Query - objectified string for highlighting, snipping, etc.

SYNOPSIS

Top

 use Search::Tools::QueryParser;
 my $qparser  = Search::Tools::QueryParser->new;
 my $query    = $qparser->parse(q(the quick color:brown "fox jumped"));
 my $terms    = $query->terms; # ['quick', 'brown', '"fox jumped"']
 my $regex    = $query->regex_for($terms->[0]); # 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




DESCRIPTION

Top

METHODS

Top

terms

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

then only foo is returned. Likewise:

 +foo -bar

would return only foo.

str

The original string.

regex

The hash ref of terms to Search::Tools::RegEx objects.

dialect

The internal Search::Query::Dialect object. See tree() and str_clean() which delegate to the dialect object.

qp

The Search::Tools::QueryParser object used to generate the Query.

from_regexp_keywords( RegExp_Keywords_object )

Class method for easing backwards compatability with the pre-0.24 API.

num_terms

Returns the number of terms().

tree

Returns the internal Search::Query::Dialect tree().

str_clean

Returns the internal Search::Query::Dialect stringify().

regex_for(term)

Returns a Search::Tools::RegEx object for term.

regexp_for

Alias for regex_for(). The author has come to prefer "regex" instead of "regexp" because it's one less keystroke.

matches_text( text )

Returns the number of matches for the query against text.

matches_html( html )

Returns the number of matches for the query against html.

terms_as_regex([treat_phrases_as_singles])

Returns all terms() as a single qr// regex, pipe-joined in a "OR" logic.

AUTHOR

Top

Peter Karman <karman@cpan.org>

BUGS

Top

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.

SUPPORT

Top

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

    perldoc Search::Tools




You can also look for information at:

* RT: CPAN's request tracker

http://rt.cpan.org/NoAuth/Bugs.html?Dist=Search-Tools

* AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/Search-Tools

* CPAN Ratings

http://cpanratings.perl.org/d/Search-Tools

* Search CPAN

http://search.cpan.org/dist/Search-Tools/

COPYRIGHT

Top

SEE ALSO

Top

Search::Query::Dialect


Search-Tools documentation  | view source Contained in the Search-Tools distribution.