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

Class: SolrHit

Source Location: /src/search/SolrHit.php

Class Overview


A document found by SolrConnection::query().


Author(s):

Implements interfaces:

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

Methods



Class Details

[line 76]
A document found by SolrConnection::query().

An instance of this class works like an associative array. If a documents contains a field with multiple values, an array is returned.

  1.  $solr Solr::connect();
  2.  $result $solr->query('php');
  3.  
  4.  $firstHit $result[0];
  5.  
  6.  echo 'This is our first hit. Solr rated it with a score of ' $firstHit->getScore("\n";
  7.  echo 'Field foo: ' $firstHit['foo'"\n";
  8.  echo 'First value for field bar: ' $firstHit['bar'][0"\n";
  9.  echo 'Second value for field bar: ' $firstHit['bar'][1"\n";

Please note that the array access is provided read-only. Any attempt to unset or change fields will lead to a BadMethodCallException.

Since instances of this class may act as SolrDocuments, you could drop them into SolrConnection::add(). This may be useful, if you want to quickly add a document found in index A to an index B.

Please note, that the hits only contain those fields requested in the corresponding query (except for the score field). See SolrQuery::setFieldList() for more details.




Tags:

author:  Alexander M. Turek <rabus@users.sourceforge.net>
since:  0.3.0


[ Top ]


Class Methods


constructor __construct [line 94]

SolrHit __construct( $jsonObject)

Constructor for SolrHit.



Tags:

access:  public


Parameters:

   $jsonObject  

[ Top ]

method count [line 167]

void count( )

Countable implementation.



Tags:

since:  0.3.1
access:  public



Implementation of:
Countable::count
[ Top ]

method current [line 131]

void current( )

Iterator implementation.



Tags:

since:  0.3.1
access:  public



Implementation of:
Iterator::current
[ Top ]

method getBoost [line 219]

float getBoost( )

SolrDocument implementation.



Tags:

access:  public



Implementation of:
SolrDocument::getBoost()
Returns the boost factor for this document.
[ Top ]

method getFields [line 230]

array(SolrField) getFields( )

SolrDocument implementation.



Tags:

access:  public
uses:  SolrSimpleField



Implementation of:
SolrDocument::getFields()
Returns the fields of this document.
[ Top ]

method getScore [line 113]

float getScore( )

Returns the score for this hit.

Returns null, if the score is not included in the result.




Tags:

access:  public


[ Top ]

method key [line 140]

void key( )

Iterator implementation.



Tags:

since:  0.3.1
access:  public



Implementation of:
Iterator::key
[ Top ]

method next [line 149]

void next( )

Iterator implementation.



Tags:

since:  0.3.1
access:  public



Implementation of:
Iterator::next
[ Top ]

method offsetExists [line 187]

boolean offsetExists( string $offset)

ArrayAccess implementation.



Tags:

access:  public



Implementation of:
ArrayAccess::offsetExists

Parameters:

string   $offset  

[ Top ]

method offsetGet [line 206]

mixed offsetGet( string $offset)

ArrayAccess implementation.



Tags:

access:  public



Implementation of:
ArrayAccess::offsetGet

Parameters:

string   $offset  

[ Top ]

method offsetSet [line 177]

void offsetSet( string $offset, mixed $value)

ArrayAccess implementation.



Tags:

access:  public



Implementation of:
ArrayAccess::offsetSet

Parameters:

string   $offset  
mixed   $value  

[ Top ]

method offsetUnset [line 196]

void offsetUnset( string $offset)

ArrayAccess implementation.



Tags:

access:  public



Implementation of:
ArrayAccess::offsetUnset

Parameters:

string   $offset  

[ Top ]

method rewind [line 122]

void rewind( )

Iterator implementation.



Tags:

since:  0.3.1
access:  public



Implementation of:
Iterator::rewind
[ Top ]

method valid [line 158]

void valid( )

Iterator implementation.



Tags:

since:  0.3.1
access:  public



Implementation of:
Iterator::valid
[ Top ]


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