final class SolrDocument implements ArrayAccess, Iterator, Serializable (View source)

(PECL solr >= 0.9.2)
Class SolrDocument
This class represents a Solr document retrieved from a query response.

Constants

SORT_DEFAULT

SORT_ASC

SORT_DESC

SORT_FIELD_NAME

SORT_FIELD_VALUE_COUNT

SORT_FIELD_BOOST_VALUE

Methods

bool
addField(string $fieldName, string $fieldValue)

(PECL solr >= 0.9.2)
Adds a field to the document

bool
clear()

(PECL solr >= 0.9.2)
Drops all the fields in the document

__clone()

(PECL solr >= 0.9.2)
Creates a copy of a SolrDocument object

__construct()

(PECL solr >= 0.9.2)
SolrDocument constructor.

mixed
current()

(PECL solr >= 0.9.2)
Retrieves the current field

bool
deleteField(string $fieldName)

(PECL solr >= 0.9.2)
Removes a field from the document

__destruct()

(PECL solr >= 0.9.2)
Destructor

bool
fieldExists(string $fieldName)

(PECL solr >= 0.9.2)
Checks if a field exists in the document

__get(string $fieldName)

(PECL solr >= 0.9.2)
Access the field as a property

getChildDocuments()

(PECL solr >= 2.3.0)
Returns an array of child documents (SolrInputDocument)

int
getChildDocumentsCount()

(PECL solr >= 2.3.0)
Returns the number of child documents

getField(string $fieldName)

(PECL solr >= 0.9.2)
Retrieves a field by name

int|false
getFieldCount()

(PECL solr >= 0.9.2)
Returns the number of fields in this document

array|false
getFieldNames()

(PECL solr >= 0.9.2)
Returns an array containing all the fields in the document

getInputDocument()

(PECL solr >= 0.9.2)
Returns a SolrInputDocument equivalent of the object

bool
hasChildDocuments()

(PECL solr >= 2.3.0)
Checks whether the document has any child documents

bool
__isset(string $fieldName)

(PECL solr >= 0.9.2)
Checks if a field exists

mixed
key()

(PECL solr >= 0.9.2)
Retrieves the current key

bool
merge(SolrInputDocument $sourceDoc, bool $overwrite = true)

(PECL solr >= 0.9.2)
Merges one input document into another

void
next()

(PECL solr >= 0.9.2)
Moves the internal pointer to the next field

bool
offsetExists(string $fieldName)

(PECL solr >= 0.9.2)
Checks if a particular field exists

mixed
offsetGet(string $fieldName)

(PECL solr >= 0.9.2)
Retrieves a field

void
offsetSet(string $fieldName, string $fieldValue)

(PECL solr >= 0.9.2)
Adds a field to the document

void
offsetUnset(string $fieldName)

(PECL solr >= 0.9.2)
Removes a field

bool
reset()

(PECL solr >= 0.9.2)
This is an alias of SolrDocument::clear

void
rewind()

(PECL solr >= 0.9.2)
Resets the internal pointer to the beginning

string|null
serialize()

(PECL solr >= 0.9.2)
Used for custom serialization

bool
__set(string $fieldName, string $fieldValue)

(PECL solr >= 0.9.2)
Adds another field to the document

bool
sort(int $sortOrderBy, int $sortDirection = SolrInputDocument::SORT_ASC)

(PECL solr >= 0.9.2)
Sorts the fields within the document

array
toArray()

(PECL solr >= 0.9.2)
Returns an array representation of the document

void
unserialize(string $serialized)

(PECL solr >= 0.9.2)
Custom serialization of SolrDocument objects

bool
__unset(string $fieldName)

(PECL solr >= 0.9.2)
Removes a field from the document

bool
valid()

(PECL solr >= 0.9.2)
Checks if the current position internally is still valid

Details

bool addField(string $fieldName, string $fieldValue)

(PECL solr >= 0.9.2)
Adds a field to the document

Parameters

string $fieldName

The name of the field

string $fieldValue

The value for the field.

Return Value

bool

Returns TRUE on success or FALSE on failure.

bool clear()

(PECL solr >= 0.9.2)
Drops all the fields in the document

Return Value

bool

Returns TRUE on success or FALSE on failure.

__clone()

(PECL solr >= 0.9.2)
Creates a copy of a SolrDocument object

__construct()

(PECL solr >= 0.9.2)
SolrDocument constructor.

mixed current()

(PECL solr >= 0.9.2)
Retrieves the current field

Return Value

mixed

Can return any type.

bool deleteField(string $fieldName)

(PECL solr >= 0.9.2)
Removes a field from the document

Parameters

string $fieldName

The name of the field.

Return Value

bool

Returns TRUE on success or FALSE on failure.

__destruct()

(PECL solr >= 0.9.2)
Destructor

bool fieldExists(string $fieldName)

(PECL solr >= 0.9.2)
Checks if a field exists in the document

Parameters

string $fieldName

Name of the field.

Return Value

bool

Returns TRUE if the field is present and FALSE if it does not.

SolrDocumentField __get(string $fieldName)

(PECL solr >= 0.9.2)
Access the field as a property

Parameters

string $fieldName

The name of the field.

Return Value

SolrDocumentField

Returns a SolrDocumentField instance.

SolrInputDocument[] getChildDocuments()

(PECL solr >= 2.3.0)
Returns an array of child documents (SolrInputDocument)

Return Value

SolrInputDocument[]

int getChildDocumentsCount()

(PECL solr >= 2.3.0)
Returns the number of child documents

Return Value

int

SolrDocumentField|false getField(string $fieldName)

(PECL solr >= 0.9.2)
Retrieves a field by name

Parameters

string $fieldName

The name of the field.

Return Value

SolrDocumentField|false

Returns a SolrDocumentField object on success and FALSE on failure

int|false getFieldCount()

(PECL solr >= 0.9.2)
Returns the number of fields in this document

Return Value

int|false

Returns an integer on success and FALSE on failure.

array|false getFieldNames()

(PECL solr >= 0.9.2)
Returns an array containing all the fields in the document

Return Value

array|false

Returns an array on success and FALSE on failure.

SolrInputDocument getInputDocument()

(PECL solr >= 0.9.2)
Returns a SolrInputDocument equivalent of the object

Return Value

SolrInputDocument

Returns a SolrInputDocument on success and NULL on failure.

bool hasChildDocuments()

(PECL solr >= 2.3.0)
Checks whether the document has any child documents

Return Value

bool

Returns TRUE if the document has any child documents

bool __isset(string $fieldName)

(PECL solr >= 0.9.2)
Checks if a field exists

Parameters

string $fieldName

Name of the field.

Return Value

bool

Returns TRUE on success or FALSE on failure.

mixed key()

(PECL solr >= 0.9.2)
Retrieves the current key

Return Value

mixed

TKey on success, or null on failure.

bool merge(SolrInputDocument $sourceDoc, bool $overwrite = true)

(PECL solr >= 0.9.2)
Merges one input document into another

Parameters

SolrInputDocument $sourceDoc

The source document.

bool $overwrite

[optional]

If this is TRUE then fields with the same name in the destination document will be overwritten.

Return Value

bool

Returns TRUE on success or FALSE on failure.

void next()

(PECL solr >= 0.9.2)
Moves the internal pointer to the next field

Return Value

void

Any returned value is ignored.

bool offsetExists(string $fieldName)

(PECL solr >= 0.9.2)
Checks if a particular field exists

Parameters

string $fieldName

The name of the field.

Return Value

bool

true on success or false on failure.

The return value will be casted to boolean if non-boolean was returned.

mixed offsetGet(string $fieldName)

(PECL solr >= 0.9.2)
Retrieves a field

Parameters

string $fieldName

The name of the field.

Return Value

mixed

Can return all value types.

void offsetSet(string $fieldName, string $fieldValue)

(PECL solr >= 0.9.2)
Adds a field to the document

Parameters

string $fieldName

The name of the field.

string $fieldValue

The value for this field.

Return Value

void

void offsetUnset(string $fieldName)

(PECL solr >= 0.9.2)
Removes a field

Parameters

string $fieldName

The name of the field.

Return Value

void

bool reset()

(PECL solr >= 0.9.2)
This is an alias of SolrDocument::clear

Return Value

bool

Returns TRUE on success or FALSE on failure.

void rewind()

(PECL solr >= 0.9.2)
Resets the internal pointer to the beginning

Return Value

void

Any returned value is ignored.

string|null serialize()

(PECL solr >= 0.9.2)
Used for custom serialization

Return Value

string|null

The string representation of the object or null

bool __set(string $fieldName, string $fieldValue)

(PECL solr >= 0.9.2)
Adds another field to the document

Parameters

string $fieldName

Name of the field.

string $fieldValue

Field value.

Return Value

bool

Returns TRUE on success or FALSE on failure.

bool sort(int $sortOrderBy, int $sortDirection = SolrInputDocument::SORT_ASC)

(PECL solr >= 0.9.2)
Sorts the fields within the document

Parameters

int $sortOrderBy

The sort criteria, must be one of :

  • SolrDocument::SORT_FIELD_NAME
  • SolrDocument::SORT_FIELD_BOOST_VALUE
  • SolrDocument::SORT_FIELD_VALUE_COUNT

int $sortDirection

[optional]

The sort direction, can be one of :

  • SolrDocument::SORT_DEFAULT
  • SolrDocument::SORT_ASC
  • SolrDocument::SORT_DESC

Return Value

bool

Returns TRUE on success or FALSE on failure.

array toArray()

(PECL solr >= 0.9.2)
Returns an array representation of the document

Return Value

array

Returns an array representation of the document.

void unserialize(string $serialized)

(PECL solr >= 0.9.2)
Custom serialization of SolrDocument objects

Parameters

string $serialized

An XML representation of the document.

Return Value

void

bool __unset(string $fieldName)

(PECL solr >= 0.9.2)
Removes a field from the document

Parameters

string $fieldName

The name of the field.

Return Value

bool

Returns TRUE on success or FALSE on failure.

bool valid()

(PECL solr >= 0.9.2)
Checks if the current position internally is still valid

Return Value

bool

The return value will be casted to boolean and then evaluated. Returns true on success or false on failure.