NAME

Elastic::Model::Role::Results - An iterator role for search results

VERSION

version 0.06

DESCRIPTION

Elastic::Model::Role::Results adds a number of methods and attributes to those provided by Elastic::Model::Role::Iterator to better handle result sets from ElasticSearch. It is used by Elastic::Model::Results and by Elastic::Model::Results::Scrolled.

See those modules for more complete documentation. This module just documents the attributes and methods added in Elastic::Model::Role::Results

ATTRIBUTES

size

$size = $results->size

The number of "elements" in the $results object;

total

$total_matching = $results->total

The total number of matching docs found by ElasticSearch. This is distinct from the "size" which contains the number of results RETURNED by ElasticSearch.

max_score

$max_score = $results->max_score

The highest score (relevance) found by ElasticSearch. Note: if you are sorting by a field other than _score then you will need to set "track_scores" in Elastic::Model::View to true to retrieve the "max_score".

facets

facet

$facets = $results->facets
$facet  = $results->facet($facet_name)

Facet results, if any were requested with "facets" in Elastic::Model::View.

elements

\@elements = $results->elements;

An array ref containing all of the data structures that we can iterate over.

\%search_args = $results->search

Contains the hash ref of the search request passed to "search()" in Elastic::Model::Role::Store

WRAPPERS

as_results()

$results = $results->as_results;

Sets the "short" accessors (eg "next" in Elastic::Model::Role::Iterator or "prev" in Elastic::Model::Role::Iterator) to return Elastic::Model::Result objects.

as_objects()

$objects = $objects->as_objects;

Sets the "short" accessors (eg "next" in Elastic::Model::Role::Iterator or "prev" in Elastic::Model::Role::Iterator) to return the object itself, eg MyApp::User

RESULT ACCESSORS

Each of the methods listed below takes the result of the related _element accessor in Elastic::Model::Role::Iterator and wrap it in an Elastic::Model::Result object. For instance:

$result = $results->next_result;

first_result

last_result

next_result

prev_result

current_result

peek_next_result

peek_prev_result

shift_result

all_results

slice_results

OBJECT ACCESSORS

Each of the methods listed below takes the result of the related _element accessor in Elastic::Model::Role::Iterator and inflate the related object (eg a MyApp::User object). For instance:

$object = $results->next_object;

first_object

last_object

next_object

prev_object

current_object

peek_next_object

peek_prev_object

shift_object

all_objects

slice_objects

AUTHOR

Clinton Gormley <drtech@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2012 by Clinton Gormley.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.