The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Data::SearchEngine::Query - Query to pass to an engine.

VERSION

version 0.31

DESCRIPTION

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.

ATTRIBUTES

count

The number of results this query should return.

debug

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.

facets

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).

filters

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.

index

The index we will be querying. Some search engine backends allow multiple indices and need this attribute.

order

The order in which the results should be sorted.

original_query

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.

page

Which page of results to show.

query

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.

type

The type of query to use. Some backends (Solr and ElasticSearch) will use a query type, if specified.

METHODS

has_debug

Returns true if this Query has a value for debug.

facet_names

Get the names of all facets.

get_facet

Get the value for the specified facet.

has_facets

Predicate that returns true if this Query has any facets. Actually, it returns the count but it does the same thing.

set_facet

Set the value for the specified facet.

filter_names

Return an array of filter names that are present in this query.

get_filter

Gets the value for the specified filter.

has_filters

Predicate that returns true if this query has filters.

set_filter

Sets the value for the specified filter.

has_index

Returns true if this query has an index specified.

has_query

Returns true if this Query has a query string.

has_type

Returns true if this Query has a type set.

digest

Returns a unique digest identifying this Query. Useful as a key when caching.

has_filter_like

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!

AUTHOR

Cory G Watson <gphat@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2011 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.