Source for file Document.php
Documentation is available at Document.php
-
-
-
* Copyright (c) 2007-2011, Servigistics, Inc.
-
-
-
* Redistribution and use in source and binary forms, with or without
-
* modification, are permitted provided that the following conditions are met:
-
-
* - Redistributions of source code must retain the above copyright notice,
-
* this list of conditions and the following disclaimer.
-
* - Redistributions in binary form must reproduce the above copyright
-
* notice, this list of conditions and the following disclaimer in the
-
* documentation and/or other materials provided with the distribution.
-
* - Neither the name of Servigistics, Inc. nor the names of
-
* its contributors may be used to endorse or promote products derived from
-
* this software without specific prior written permission.
-
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-
* POSSIBILITY OF SUCH DAMAGE.
-
-
* @copyright Copyright 2007-2011 Servigistics, Inc. (http://servigistics.com)
-
* @license http://solr-php-client.googlecode.com/svn/trunk/COPYING New BSD
-
* @version $Id: Document.php 54 2011-02-04 16:29:18Z donovan.jimenez $
-
-
-
-
* @author Donovan Jimenez <djimenez@conduit-it.com>
-
-
-
-
* Holds Key / Value pairs that represent a Solr Document along with any associated boost
-
* values. Field values can be accessed by direct dereferencing such as:
-
-
-
* $document->title = 'Something';
-
-
-
-
-
* Additionally, the field values can be iterated with foreach
-
-
-
* foreach ($document as $fieldName => $fieldValue)
-
-
-
-
-
-
-
-
-
* SVN Revision meta data for this class
-
-
const SVN_REVISION =
'$Revision: 54 $';
-
-
-
* SVN ID meta data for this class
-
-
const SVN_ID =
'$Id: Document.php 54 2011-02-04 16:29:18Z donovan.jimenez $';
-
-
-
-
-
-
-
-
-
-
* Document field values, indexed by name
-
-
-
-
-
-
-
* Document field boost values, indexed by name
-
-
* @var array array of floats
-
-
-
-
-
* Clear all boosts and fields from this document
-
-
-
-
-
-
-
-
-
-
-
* Get current document boost
-
-
* @return mixed will be false for default, or else a float
-
-
-
-
-
-
-
-
* Set document boost factor
-
-
* @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
* Add a value to a multi-valued field
-
-
* NOTE: the solr XML format allows you to specify boosts
-
* PER value even though the underlying Lucene implementation
-
* only allows a boost per field. To remedy this, the final
-
* field boost value will be the product of all specified boosts
-
* on field values - this is similar to SolrJ's functionality.
-
-
-
* $doc = new Apache_Solr_Document();
-
-
* $doc->addField('foo', 'bar', 2.0);
-
* $doc->addField('foo', 'baz', 3.0);
-
-
* // resultant field boost will be 6!
-
* echo $doc->getFieldBoost('foo');
-
-
-
-
-
* @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false
-
-
public function addField($key, $value, $boost =
false)
-
-
-
-
// create holding array if this is the first value
-
-
-
-
-
// move existing value into array if it is not already an array
-
-
-
-
-
-
// boost not already set, set it now
-
-
-
else if ((float)
$boost >
0.0)
-
-
// multiply passed boost with current field boost - similar to SolrJ implementation
-
-
-
-
-
-
-
-
-
* Handle the array manipulation for a multi-valued field
-
-
-
-
* @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false
-
-
* @deprecated Use addField(...) instead
-
-
-
-
-
-
-
-
-
-
-
* @return mixed associative array of info if field exists, false otherwise
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
* Set a field value. Multi-valued fields should be set as arrays
-
* or instead use the addField(...) function which will automatically
-
* make sure the field is an array.
-
-
-
-
* @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false
-
-
public function setField($key, $value, $boost =
false)
-
-
-
-
-
-
-
* Get the currently set field boost for a document field
-
-
-
* @return float currently set field boost, false if one is not set
-
-
-
-
-
-
-
-
* Set the field boost for a document field
-
-
* @param string $key field name for the boost
-
* @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
* Return current field boosts, indexed by field name
-
-
-
-
-
-
-
-
-
-
* Get the names of all fields in this document
-
-
-
-
-
-
-
-
-
-
* Get the values of all fields in this document
-
-
-
-
-
-
-
-
-
-
* IteratorAggregate implementation function. Allows usage:
-
-
-
* foreach ($document as $key => $value)
-
-
-
-
-
-
-
-
$arrayObject =
new ArrayObject($this->_fields);
-
-
return $arrayObject->getIterator();
-
-
-
-
* Magic get for field values
-
-
-
-
-
public function __get($key)
-
-
-
-
-
-
-
-
-
-
-
* Magic set for field values. Multi-valued fields should be set as arrays
-
* or instead use the addField(...) function which will automatically
-
* make sure the field is an array.
-
-
-
-
-
public function __set($key, $value)
-
-
-
-
-
-
* Magic isset for fields values. Do not call directly. Allows usage:
-
-
-
* isset($document->some_field);
-
-
-
-
-
-
-
-
return isset
($this->_fields[$key]);
-
-
-
-
* Magic unset for field values. Do not call directly. Allows usage:
-
-
-
* unset($document->some_field);
-
-
-
-
-
-
-
-
-
-
Documentation generated on Wed, 04 May
2011 11:01:13 -0400 by phpDocumentor
1.4.3