php_solr
[ class tree: php_solr ] [ index: php_solr ] [ all elements ]

Class: SolrSearchResult

Source Location: /src/search/SolrSearchResult.php

Class Overview


A search result.


Author(s):

Implements interfaces:

  • Iterator (internal interface)
  • Countable (internal interface)
  • ArrayAccess (internal interface)

Methods



Class Details

[line 90]
A search result.

An instance of this class is returned by SolrConnection::query(). This object represents a the result of the query sent. It may be browsed via a foreach loop as if it was an array of SolrHit objects.

  1.  require_once 'php_solr/Solr.php';
  2.  
  3.  $solr Solr::connect();
  4.  $result $solr->query('php');
  5.  
  6.  echo 'We have found ' $result->getNumFound(' documents total.' "\n";
  7.  echo 'Our result set contains ' count($result' documents.' "\n";
  8.  echo 'Let\'s start with document no. ' $result->getStart('.' "\n";
  9.  
  10.  foreach ($result as $currentHit{
  11.      assert($currentHit instanceof SolrHit);
  12.      // do something
  13.  }

Alternatively, the hits can be accessed by index:

  1.  for ($i 0$i count($result)$i++{
  2.      $currentHit $result[$i];
  3.      assert($currentHit instanceof SolrHit);
  4.      // do something
  5.  }

The array access is provided read-only. Any attempt to unset or change array elements will result in a BadMethodCallException.

If there are facets attached to the result, you can access them via the $facets property. Please refer to SolrFacetCounts for more details.




Tags:

property-read:  SolrFacetCounts $facets: The facets attached to this result.
author:  Alexander M. Turek <rabus@users.sourceforge.net>
since:  0.3.0


[ Top ]


Class Methods


static method parseResponse [line 151]

static SolrSearchResult parseResponse( string $response)

Parses the JSON response of the StandardRequestHandler.



Tags:

access:  public
uses:  json_decode


Parameters:

string   $response  

[ Top ]

method count [line 235]

void count( )

Countable implementation.



Tags:

access:  public



Implementation of:
Countable::count
[ Top ]

method current [line 199]

void current( )

Iterator implementation.



Tags:

access:  public



Implementation of:
Iterator::current
[ Top ]

method getNumFound [line 185]

integer getNumFound( )

Returns the total number of documents found.



Tags:

access:  public


[ Top ]

method getStart [line 176]

integer getStart( )

Returns the result offset.



Tags:

access:  public


[ Top ]

method key [line 210]

void key( )

Iterator implementation.



Tags:

access:  public



Implementation of:
Iterator::key
[ Top ]

method next [line 217]

void next( )

Iterator implementation.



Tags:

access:  public



Implementation of:
Iterator::next
[ Top ]

method offsetExists [line 255]

boolean offsetExists( string $offset)

ArrayAccess implementation.



Tags:

access:  public



Implementation of:
ArrayAccess::offsetExists

Parameters:

string   $offset  

[ Top ]

method offsetGet [line 274]

mixed offsetGet( string $offset)

ArrayAccess implementation.



Tags:

access:  public



Implementation of:
ArrayAccess::offsetGet

Parameters:

string   $offset  

[ Top ]

method offsetSet [line 245]

void offsetSet( string $offset, mixed $value)

ArrayAccess implementation.



Tags:

access:  public



Implementation of:
ArrayAccess::offsetSet

Parameters:

string   $offset  
mixed   $value  

[ Top ]

method offsetUnset [line 264]

void offsetUnset( string $offset)

ArrayAccess implementation.



Tags:

access:  public



Implementation of:
ArrayAccess::offsetUnset

Parameters:

string   $offset  

[ Top ]

method rewind [line 192]

void rewind( )

Iterator implementation.



Tags:

access:  public



Implementation of:
Iterator::rewind
[ Top ]

method valid [line 228]

void valid( )

Iterator implementation.



Tags:

access:  public



Implementation of:
Iterator::valid
[ Top ]

method __get [line 130]

mixed __get( string $property)

Getter for magic properties.



Tags:

access:  public


Parameters:

string   $property   The parameter.

[ Top ]


Documentation generated on Wed, 20 May 2009 12:51:11 +0000 by phpDocumentor 1.4.2