Data::SearchEngine::Query - Query to pass to an engine.
version 0.33
The query object has some common attributes one would expect when performing a search. It has the added benefit of producing a digest that can be used with Data::SearchEngine::Results ability to serialize to implement caching.
If you add new attributes to a subclass, be sure and add the Digestable trait to any attributes you want to be included in the digest as document in Data::SearchEngine::Meta::Attribute::Trait::Digestable.
The number of results this query should return.
A string value denoting that this query should include debugging information in the response. Uses a string as the type because some search indexes allow you to specify the type of debugging. For those that just use a flag, the predicate should be checked so that any true value results in debugging.
A HashRef of facets used with the query. The key should be the facet name and the value is the facet's value. Consult the documentation for your backend to see how this is used (if at all).
The fields to return. Some search engine backends allow you to only return part of a document.
A HashRef of filters used with the query. The key should be the filter name and the value is the filter's value. Consult the documentation for your backend to see how this is used.
The index we will be querying. Some search engine backends allow multiple indices and need this attribute.
The order in which the results should be sorted.
The "original" query that the user searched for. Provided because some backends may need to modify the query attribute to a more palatable form. If no value is provided for this attribute then it will assume the same value as query.
query
Which page of results to show.
The query string to search for. This attribute may be a Str, ArrayRef or a HashRef. Some backends (like ElasticSearch) require complex data structures to perform searches and need a HashRef for their queries. NOTE: It is advised that you set original_query to a string so that the results object has a clean string to show end-users.
original_query
The type of query to use. Some backends (Solr and ElasticSearch) will use a query type, if specified.
Returns true if this Query has a value for debug.
Get the names of all facets.
Get the value for the specified facet.
Predicate that returns true if this Query has any facets. Actually, it returns the count but it does the same thing.
Set the value for the specified facet.
Returns true if this query has fields specified.
Return an array of filter names that are present in this query.
Gets the value for the specified filter.
Predicate that returns true if this query has filters.
Sets the value for the specified filter.
Returns true if this query has an index specified.
Returns true if this Query has a query string.
Returns true if this Query has a type set.
Returns a unique digest identifying this Query. Useful as a key when caching.
Returns true if any of the filter names match the provided subroutine:
$query->set_filter('foo', 'bar'); $query->has_filter_like(sub { /^fo/ })s; # true!
Cory G Watson <gphat@cpan.org>
This software is copyright (c) 2012 by Cold Hard Code, LLC.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Data::SearchEngine, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::SearchEngine
CPAN shell
perl -MCPAN -e shell install Data::SearchEngine
For more information on module installation, please visit the detailed CPAN module installation guide.