Peter Karman
and 1 contributors

NAME

Search::OpenSearch::Response - provide search results in OpenSearch format

SYNOPSIS

 use Search::OpenSearch;
 my $engine = Search::OpenSearch->engine(
    type    => 'Lucy',
    index   => [qw( path/to/index1 path/to/index2 )],
    facets  => {
        names       => [qw( color size flavor )],
        sample_size => 10_000,
    },
    fields  => [qw( color size flavor )],
 );
 my $response = $engine->search(
    q           => 'quick brown fox',   # query
    s           => 'score desc',        # sort order
    o           => 0,                   # offset
    p           => 25,                  # page size
    h           => 1,                   # highlight query terms in results
    c           => 0,                   # return count stats only (no results)
    L           => 'field|low|high',    # limit results to inclusive range
    f           => 1,                   # include facets
    r           => 1,                   # include results
    format      => 'XML',               # or JSON
    b           => 'AND',               # or OR
 );
 print $response;

DESCRIPTION

Search::OpenSearch::Response is an abstract base class with some common methods for all Response subclasses.

METHODS

This class is a subclass of Moose. Only new or overridden methods are documented here.

get_version

Returns the package var $VERSION string by default.

new( params )

The following standard get/set attribute methods are available:

debug
results

An interator object behaving like SWISH::Prog::Results.

total
offset
page_size
fields
facets
query
parsed_query

As returned by Search::Query.

json_query

Same as parsed_query, but the object tree is JSON encoded instead of stringified.

author
pps

Pages-per-section. Used by Data::Pageset. Default is "10".

title
search_time
build_time
engine
sort_info
version
suggestions
mtime_field

The results field to use for the last-modified logic in get_mtime(). The default is mtime. The field value should be an integer.

build_pager

Returns Data::Pageset object based on offset() and page_size().

as_hash

Returns the Response object as a hash ref of key/value pairs.

get_mtime

Returns an integer representing the most recent mtime of the current set of results.

stringify

Returns the Response in the chosen serialization format.

Response objects are overloaded to call stringify().

add_attribute( attribute_name )

Adds get/set method attribute_name to the class and will include that attribute in as_hash(). This method is intended to make it easier to extend the basic structure without needing to subclass.

default_fields

Returns array ref of default result field names. These are implemented by the default Engine class.

error

Get/set error value for the Response. This value is not included in the stringify() output, but can be used to set or check for errors in processing.

init_author

Builder method for the author.

init_title

Builder method for title.

Builder method for link.

init_offset

Builder method for offset.

init_page_size

Builder method for page_size.

init_attr_blacklist

Builder method for attr_blacklist. This hashref of attribute names registers which attributes are excluded by stringify().

init_mtime_field

Builder method for mtime_field.

AUTHOR

Peter Karman, <karman at cpan.org>

BUGS

Please report any bugs or feature requests to bug-search-opensearch at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Search-OpenSearch. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

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

    perldoc Search::OpenSearch::Response

You can also look for information at:

COPYRIGHT & LICENSE

Copyright 2010 Peter Karman.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.