Apache-Solr

 view release on metacpan or  search on metacpan

lib/Apache/Solr/Result.pod  view on Meta::CPAN

=encoding utf8

=head1 NAME

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

=head1 SYNOPSIS

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

  $result->success or die $result->solrError; # error reported by Solr
  $result->success or die $result->errors;    # any error caught by this object
  if($result)  # same as if($result->success)

  # Lots of trace information included
  $result->showTimings;

  # ::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;

=head1 DESCRIPTION

=head1 METHODS

=head2 Constructors

=over 4

=item Apache::Solr::Result-E<gt>B<new>(%options)

 -Option    --Default
  core        undef
  endpoint    <required>
  params      []
  request     undef
  response    undef
  sequential  false

=over 2

=item core => L<Apache::Solr|Apache::Solr> object

=item endpoint => URI

=item params => ARRAY|HASH

The parameters used for the query.  [1.11] not required anymore.

=item request => HTTP::Request object

=item response => HTTP::Response object

=item sequential => BOOLEAN

[1.06] By setting this, you indicate that you will process the documents
in (numeric) sequential order; that you have no intention to go back to
a lower number.  This implies that those cached results can be cleaned-up
in the client early, reducing memory consumption.

However: you are allowed to go back to lower numbers, with the penalty
of a repeat of a message exchange between this client and the database.

=back

=back

=head2 Accessors

=over 4

=item $obj-E<gt>B<core>()

[0.95] May return the L<Apache::Solr|Apache::Solr> object which created this result.

=item $obj-E<gt>B<decoded>( [HASH] )

Set/get the decoded content of the Solr server response.  In some cases,
even error responses contain a valid Solr server data.

=item $obj-E<gt>B<elapse>()

Number of seconds used to receive a decoded answer.

=item $obj-E<gt>B<endpoint>()

The URI where the request is sent to.

=item $obj-E<gt>B<errors>()

All errors collected by this object into one string.

=item $obj-E<gt>B<httpError>()

=item $obj-E<gt>B<params>()

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

=item $obj-E<gt>B<request>( [$request] )

Set/get the HTTP::Request object used in this query.

=item $obj-E<gt>B<response>( [$response] )

Set/get the HTTP::Response object received from this query action.

=item $obj-E<gt>B<sequential>()

[1.06] Shows whether the results are only read in numeric order.

=item $obj-E<gt>B<serverError>()

=item $obj-E<gt>B<solrError>()

=item $obj-E<gt>B<solrQTime>()

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

=item $obj-E<gt>B<solrStatus>()

=item $obj-E<gt>B<start>()

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

=item $obj-E<gt>B<success>()

Returns true if the command has successfully completed.  

example: 

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

=back

=head2 Response information

=head3 in response to a select()

=over 4

=item $obj-E<gt>B<highlighted>($document)

Return information which relates to the selected $document.

=item $obj-E<gt>B<nextSelected>(%options)

[0.95] Produces the next document, or C<undef> when there are none left.
[1.06] Use L<selected()|Apache::Solr::Result/"in response to a select()"> or search parameter C<start> to give a starting
point.  [1.06] The C<%options> are passed to L<selected()|Apache::Solr::Result/"in response to a select()">.

example: 

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



( run in 0.524 second using v1.01-cache-2.11-cpan-f56aa216473 )