Elastic::Model::Role::Results - An iterator role for search results
version 0.52
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
$size = $results->size
The number of "elements" in the $results object;
$results
$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 = $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".
_score
$aggs = $results->aggs $agg = $results->agg($agg_name)
Aggregation results, if any were requested with "aggs" in Elastic::Model::View.
$facets = $results->facets $facet = $results->facet($facet_name)
Facet results, if any were requested with "facets" in Elastic::Model::View.
\@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
$bool = $result->is_partial
Returns true or false to indicate whether the specified search returns full or partial results.
true
false
$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.
$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
MyApp::User
$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.
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:
_element
$result = $results->next_result;
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;
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;
Clinton Gormley <drtech@cpan.org>
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.
To install Elastic::Model, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Elastic::Model
CPAN shell
perl -MCPAN -e shell install Elastic::Model
For more information on module installation, please visit the detailed CPAN module installation guide.