Search::Elasticsearch::Compat::ScrolledSearch - A wrapper for managing scrolled searches
version 0.10
$scroller = $es->scrolled_search($search_params); OR $scroller = Search::Elasticsearch::Compat::ScrolledSearch($es,$search_params); while (my $result = $scroller->next) { # do something } $total = $scroller->total; $bool = $scroller->eof $score = $scroller->max_score; $facets = $scroller->facets;
Search::Elasticsearch::Compat::ScrolledSearch is a convenience iterator for scrolled searches. It accepts the standard search parameters that would be passed to "search()" in Search::Elasticsearch::Compat. The scroll parameter defaults to 1m.
Search::Elasticsearch::Compat::ScrolledSearch
scroll
1m
$scroller = $es->scrolled_search( query => {match_all=>{}}, scroll => '5m' # keep the scroll request # live for 5 minutes );
new()
$scroller = $es->scrolled_search($search_params); OR $scroller = Search::Elasticsearch::Compat::ScrolledSearch($es,$search_params);
@results = $scroller->next() @results = $scroller->next($no_of_results);
Returns the next result, or the next $no_of_results or an empty list when no more results are available.
$no_of_results
An error is thrown if the scroll has already expired.
If as_json => 1 is specified, then "next()" will always return a JSON array:
as_json => 1
$scroller->next() # '[{...}]' $scroller->next(2) # '[{...},{...}]' # if no results left: '[]'
@docs = $scroller->drain_buffer;
Returns and removes all docs that are currently stored in the buffer.
$buffer_size = $scroller->refill_buffer
Pulls the next set of results from Elasticsearch (if any) and returns the total number of docs stored in the internal buffer.
$total = $scroller->total
The total number of hits
$score = $scroller->max_score
The max_score returned from the first search request (if available).
max_score
$bool = $scroller->eof
Returns true if no more results are available. Note: if no results match the search, then eof() could be false but the first call to next() will return zero results.
true
eof()
false
next()
$facets = $scroller->facets
The facets returned from the first search request (if any).
facets
If as_json => 1 is specified, then "facets()" will always return a JSON object.
"scrolled_search()" in Search::Elasticsearch::Client::Compat, "search()" in Search::Elasticsearch::Client::Compat and "scroll()" in Search::Elasticsearch::Client::Compat
Clinton Gormley <drtech@cpan.org>
This software is Copyright (c) 2014 by Elasticsearch BV.
This is free software, licensed under:
The Apache License, Version 2.0, January 2004
To install Search::Elasticsearch::Compat, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Search::Elasticsearch::Compat
CPAN shell
perl -MCPAN -e shell install Search::Elasticsearch::Compat
For more information on module installation, please visit the detailed CPAN module installation guide.