++ed by:

1 PAUSE user

Mark Overmeer
and 1 contributors


Apache::Solr::Result - Apache Solr (Lucene) result container


  # All operations return a ::Result object
  my $result = $solr->select(...);

  $result or die $result->solrError; # error reported by Solr
  $result or die $result->errors;    # any error caught by this object

  # Lots of trace information included

  # ::Document containing the requested fields from a select() search
  my $doc1   = $result->selected(0);

  # ::Document containing the highlight info from a selected document
  my $hl1    = $result->highlighted($doc1);

  # Some operations have helper methods
  my $result = $solr->queryTerm(...);
  print Dumper $result->terms;




 -Option  --Default
  core      undef
  endpoint  <required>
  params    <required>
  request   undef
  response  undef
core => Apache::Solr object
endpoint => URI
params => ARRAY
request => HTTP::Request object
response => HTTP::Response object



[0.95] May return the Apache::Solr object which created this result.

$obj->decoded( [HASH] )

Number of seconds used to receive a decoded answer.


The URI where the request is sent to.


All errors collected by this object into one string.


List of (expanded) parameters used to call the solr server.

$obj->request( [$request] )
$obj->response( [$response] )

Elapse (as reported by the server) to handle the request. In seconds!


The timestamp of the moment the call has started, including the creation of the message to be sent.


Returns true if the command has successfully completed.


   my $result = $sorl->commit;
   $result->success or die;
   $result or die;          # same, via overloading
   $solr->commit or die;    # same, also overloading

Response information

in response to a select()


Return information which relates to the selected $document.


[0.95] Produces the next document, or undef when all have been produced.


  my $result = $solr->select(q => ...);
  while(my $doc = $result->nextSelected)
  {   my $hl = $result->highlighted($doc);

Returns the number of selected documents, as result of a Apache::Solr::select() call. Probably many of those documents are not loaded (yet).


  print $result->nrSelected, " results\n";

  for(my $docnr = 0; $docnr < $result->nrSelected; $docnr++)
  {   my $doc = $result->selected($docnr);
  # easier:
  while(my $doc = $result->nextSelected) ...

Returns information about the query by Apache::Solr::select() on position $rank (count starts at 0) Returned is a Apache::Solr::Document object.

The first request will take a certain number of "rows". This routine will automatically collect more of the selected answers, when you address results outside the first "page" of "rows". The results of these other requests are cached as well.


   my $r = $solr->select(rows => 10, ...);
   $r or die $r->errors;

   if(my $last = $r->selected(9)) {...}
   my $elf = $r->selected(11);         # auto-request more

in response to a queryTerms()

$obj->terms( $field, [$terms] )

Returns the results of a 'terms' query (see Apache::Solr::queryTerms()), which is a HASH. When $terms are specified, a new table is set.

In Solr XML (at least upto v4.0) the results are presented as lst, not arr So: their sort order is lost.


$obj->replaceParams(HASH, $oldparams)
$obj->selectedPageLoad($rank, $client)
$obj->showTimings( [$fh] )

Print timing informat to the $fh, by default the selected file-handle (probably STDOUT).


overload: stringification


This module is part of Apache-Solr distribution version 1.04, built on May 23, 2016. Website: http://perl.overmeer.net


Copyrights 2012-2016 by [Mark Overmeer]. For other contributors see ChangeLog.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html