summaryrefslogtreecommitdiff
path: root/vendor/ruflin/elastica/lib/Elastica/Document.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/ruflin/elastica/lib/Elastica/Document.php')
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Document.php122
1 files changed, 72 insertions, 50 deletions
diff --git a/vendor/ruflin/elastica/lib/Elastica/Document.php b/vendor/ruflin/elastica/lib/Elastica/Document.php
index 3f6b88de..e82afae9 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Document.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Document.php
@@ -1,17 +1,13 @@
<?php
-
namespace Elastica;
-use Elastica\Exception\InvalidException;
use Elastica\Bulk\Action;
-use Elastica\Filter\Bool;
+use Elastica\Exception\InvalidException;
use Elastica\Exception\NotImplementedException;
/**
- * Single document stored in elastic search
+ * Single document stored in elastic search.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
*/
class Document extends AbstractUpdateAction
@@ -19,7 +15,7 @@ class Document extends AbstractUpdateAction
const OP_TYPE_CREATE = Action::OP_TYPE_CREATE;
/**
- * Document data
+ * Document data.
*
* @var array Document data
*/
@@ -28,22 +24,22 @@ class Document extends AbstractUpdateAction
/**
* Whether to use this document to upsert if the document does not exist.
*
- * @var boolean
+ * @var bool
*/
protected $_docAsUpsert = false;
/**
- * @var boolean
+ * @var bool
*/
protected $_autoPopulate = false;
/**
- * Creates a new document
+ * Creates a new document.
*
- * @param int|string $id OPTIONAL $id Id is create if empty
- * @param array|string $data OPTIONAL Data array
- * @param string $type OPTIONAL Type name
- * @param string $index OPTIONAL Index name
+ * @param int|string $id OPTIONAL $id Id is create if empty
+ * @param array|string $data OPTIONAL Data array
+ * @param string $type OPTIONAL Type name
+ * @param string $index OPTIONAL Index name
*/
public function __construct($id = '', $data = array(), $type = '', $index = '')
{
@@ -55,6 +51,7 @@ class Document extends AbstractUpdateAction
/**
* @param string $key
+ *
* @return mixed
*/
public function __get($key)
@@ -64,7 +61,7 @@ class Document extends AbstractUpdateAction
/**
* @param string $key
- * @param mixed $value
+ * @param mixed $value
*/
public function __set($key, $value)
{
@@ -73,6 +70,7 @@ class Document extends AbstractUpdateAction
/**
* @param string $key
+ *
* @return bool
*/
public function __isset($key)
@@ -90,22 +88,27 @@ class Document extends AbstractUpdateAction
/**
* @param string $key
- * @return mixed
+ *
* @throws \Elastica\Exception\InvalidException
+ *
+ * @return mixed
*/
public function get($key)
{
if (!$this->has($key)) {
throw new InvalidException("Field {$key} does not exist");
}
+
return $this->_data[$key];
}
/**
* @param string $key
- * @param mixed $value
+ * @param mixed $value
+ *
* @throws \Elastica\Exception\InvalidException
- * @return \Elastica\Document
+ *
+ * @return $this
*/
public function set($key, $value)
{
@@ -119,6 +122,7 @@ class Document extends AbstractUpdateAction
/**
* @param string $key
+ *
* @return bool
*/
public function has($key)
@@ -128,8 +132,10 @@ class Document extends AbstractUpdateAction
/**
* @param string $key
+ *
* @throws \Elastica\Exception\InvalidException
- * @return \Elastica\Document
+ *
+ * @return $this
*/
public function remove($key)
{
@@ -142,12 +148,14 @@ class Document extends AbstractUpdateAction
}
/**
- * Adds the given key/value pair to the document
+ * Adds the given key/value pair to the document.
*
* @deprecated
- * @param string $key Document entry key
- * @param mixed $value Document entry value
- * @return \Elastica\Document
+ *
+ * @param string $key Document entry key
+ * @param mixed $value Document entry value
+ *
+ * @return $this
*/
public function add($key, $value)
{
@@ -155,7 +163,7 @@ class Document extends AbstractUpdateAction
}
/**
- * Adds a file to the index
+ * Adds a file to the index.
*
* To use this feature you have to call the following command in the
* elasticsearch directory:
@@ -165,17 +173,18 @@ class Document extends AbstractUpdateAction
* This installs the tika file analysis plugin. More infos about supported formats
* can be found here: {@link http://tika.apache.org/0.7/formats.html}
*
- * @param string $key Key to add the file to
- * @param string $filepath Path to add the file
- * @param string $mimeType OPTIONAL Header mime type
- * @return \Elastica\Document
+ * @param string $key Key to add the file to
+ * @param string $filepath Path to add the file
+ * @param string $mimeType OPTIONAL Header mime type
+ *
+ * @return $this
*/
public function addFile($key, $filepath, $mimeType = '')
{
$value = base64_encode(file_get_contents($filepath));
if (!empty($mimeType)) {
- $value = array('_content_type' => $mimeType, '_name' => $filepath, 'content' => $value,);
+ $value = array('_content_type' => $mimeType, '_name' => $filepath, '_content' => $value);
}
$this->set($key, $value);
@@ -184,11 +193,12 @@ class Document extends AbstractUpdateAction
}
/**
- * Add file content
+ * Add file content.
+ *
+ * @param string $key Document key
+ * @param string $content Raw file content
*
- * @param string $key Document key
- * @param string $content Raw file content
- * @return \Elastica\Document
+ * @return $this
*/
public function addFileContent($key, $content)
{
@@ -196,19 +206,21 @@ class Document extends AbstractUpdateAction
}
/**
- * Adds a geopoint to the document
+ * Adds a geopoint to the document.
*
* Geohashes are not yet supported
*
* @param string $key Field key
* @param float $latitude Latitude value
* @param float $longitude Longitude value
- * @link http://www.elasticsearch.org/guide/reference/mapping/geo-point-type.html
- * @return \Elastica\Document
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-geo-point-type.html
+ *
+ * @return $this
*/
public function addGeoPoint($key, $latitude, $longitude)
{
- $value = array('lat' => $latitude, 'lon' => $longitude,);
+ $value = array('lat' => $latitude, 'lon' => $longitude);
$this->set($key, $value);
@@ -216,10 +228,11 @@ class Document extends AbstractUpdateAction
}
/**
- * Overwrites the current document data with the given data
+ * Overwrites the current document data with the given data.
*
- * @param array|string $data Data array
- * @return \Elastica\Document
+ * @param array|string $data Data array
+ *
+ * @return $this
*/
public function setData($data)
{
@@ -229,7 +242,7 @@ class Document extends AbstractUpdateAction
}
/**
- * Returns the document data
+ * Returns the document data.
*
* @return array|string Document data
*/
@@ -239,36 +252,41 @@ class Document extends AbstractUpdateAction
}
/**
+ * @deprecated
+ *
* @param \Elastica\Script $data
+ *
* @throws NotImplementedException
- * @deprecated
*/
public function setScript($data)
{
- throw new NotImplementedException("setScript() is no longer available as of 0.90.2. See http://elastica.io/migration/0.90.2/upsert.html to migrate");
+ throw new NotImplementedException('setScript() is no longer available as of 0.90.2. See http://elastica.io/migration/0.90.2/upsert.html to migrate');
}
/**
* @throws NotImplementedException
+ *
* @deprecated
*/
public function getScript()
{
- throw new NotImplementedException("getScript() is no longer available as of 0.90.2. See http://elastica.io/migration/0.90.2/upsert.html to migrate");
+ throw new NotImplementedException('getScript() is no longer available as of 0.90.2. See http://elastica.io/migration/0.90.2/upsert.html to migrate');
}
/**
* @throws NotImplementedException
+ *
* @deprecated
*/
public function hasScript()
{
- throw new NotImplementedException("hasScript() is no longer available as of 0.90.2. See http://elastica.io/migration/0.90.2/upsert.html to migrate");
+ throw new NotImplementedException('hasScript() is no longer available as of 0.90.2. See http://elastica.io/migration/0.90.2/upsert.html to migrate');
}
/**
* @param bool $value
- * @return \Elastica\Document
+ *
+ * @return $this
*/
public function setDocAsUpsert($value)
{
@@ -278,7 +296,7 @@ class Document extends AbstractUpdateAction
}
/**
- * @return boolean
+ * @return bool
*/
public function getDocAsUpsert()
{
@@ -287,6 +305,7 @@ class Document extends AbstractUpdateAction
/**
* @param bool $autoPopulate
+ *
* @return $this
*/
public function setAutoPopulate($autoPopulate = true)
@@ -305,7 +324,8 @@ class Document extends AbstractUpdateAction
}
/**
- * Returns the document as an array
+ * Returns the document as an array.
+ *
* @return array
*/
public function toArray()
@@ -317,9 +337,11 @@ class Document extends AbstractUpdateAction
}
/**
- * @param array|\Elastica\Document $data
+ * @param array|\Elastica\Document $data
+ *
* @throws \Elastica\Exception\InvalidException
- * @return \Elastica\Document
+ *
+ * @return self
*/
public static function create($data)
{