NAME

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

VERSION

version 0.52

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, Elastic::Model::Results::Cached 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".

aggs

agg

$aggs = $results->aggs
$agg  = $results->agg($agg_name)

Aggregation results, if any were requested with "aggs" in Elastic::Model::View.

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

is_partial

$bool = $result->is_partial

Returns true or false to indicate whether the specified search returns full or partial results.

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

as_partials()

$results->as_partials()

Sets the "short" accessors (eg "next" in Elastic::Model::Role::Iterator or "prev" in Elastic::Model::Role::Iterator) to return partial objects as specified by "include_paths / exclude_paths" in Elastic::Model::View.

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 inflates 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

PARTIAL OBJECT ACCESSORS

Each of the methods listed below takes the result of the related _element accessor in Elastic::Model::Role::Iterator and inflates the related partial object as specified by "include_paths / exclude_paths" in Elastic::Model::View. For instance:

$object = $results->next_partial;

first_partial

last_partial

next_partial

prev_partial

current_partial

peek_next_partial

peek_prev_partial

shift_partial

all_partials

slice_partials

AUTHOR

Clinton Gormley <drtech@cpan.org>

COPYRIGHT AND LICENSE

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