summaryrefslogtreecommitdiff
path: root/vendor/ruflin/elastica/lib/Elastica/AbstractUpdateAction.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/ruflin/elastica/lib/Elastica/AbstractUpdateAction.php')
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/AbstractUpdateAction.php142
1 files changed, 83 insertions, 59 deletions
diff --git a/vendor/ruflin/elastica/lib/Elastica/AbstractUpdateAction.php b/vendor/ruflin/elastica/lib/Elastica/AbstractUpdateAction.php
index 883284ae..468087af 100644
--- a/vendor/ruflin/elastica/lib/Elastica/AbstractUpdateAction.php
+++ b/vendor/ruflin/elastica/lib/Elastica/AbstractUpdateAction.php
@@ -1,13 +1,10 @@
<?php
-
namespace Elastica;
/**
* Base class for things that can be sent to the update api (Document and
* Script).
*
- * @category Xodoa
- * @package Elastica
* @author Nik Everett <nik9000@gmail.com>
*/
class AbstractUpdateAction extends Param
@@ -20,8 +17,9 @@ class AbstractUpdateAction extends Param
/**
* Sets the id of the document.
*
- * @param string $id
- * @return \Elastica\Document
+ * @param string $id
+ *
+ * @return $this
*/
public function setId($id)
{
@@ -29,7 +27,7 @@ class AbstractUpdateAction extends Param
}
/**
- * Returns document id
+ * Returns document id.
*
* @return string|int Document id
*/
@@ -47,10 +45,11 @@ class AbstractUpdateAction extends Param
}
/**
- * Sets lifetime of document
+ * Sets lifetime of document.
*
- * @param string $ttl
- * @return \Elastica\Document
+ * @param string $ttl
+ *
+ * @return $this
*/
public function setTtl($ttl)
{
@@ -74,10 +73,11 @@ class AbstractUpdateAction extends Param
}
/**
- * Sets the document type name
+ * Sets the document type name.
+ *
+ * @param string $type Type name
*
- * @param string $type Type name
- * @return \Elastica\Document Current object
+ * @return $this
*/
public function setType($type)
{
@@ -85,14 +85,16 @@ class AbstractUpdateAction extends Param
$this->setIndex($type->getIndex());
$type = $type->getName();
}
+
return $this->setParam('_type', $type);
}
/**
- * Return document type name
+ * Return document type name.
*
- * @return string Document type name
* @throws \Elastica\Exception\InvalidException
+ *
+ * @return string Document type name
*/
public function getType()
{
@@ -100,24 +102,27 @@ class AbstractUpdateAction extends Param
}
/**
- * Sets the document index name
+ * Sets the document index name.
+ *
+ * @param string $index Index name
*
- * @param string $index Index name
- * @return \Elastica\Document Current object
+ * @return $this
*/
public function setIndex($index)
{
if ($index instanceof Index) {
$index = $index->getName();
}
+
return $this->setParam('_index', $index);
}
/**
- * Get the document index name
+ * Get the document index name.
*
- * @return string Index name
* @throws \Elastica\Exception\InvalidException
+ *
+ * @return string Index name
*/
public function getIndex()
{
@@ -125,11 +130,13 @@ class AbstractUpdateAction extends Param
}
/**
- * Sets the version of a document for use with optimistic concurrency control
+ * Sets the version of a document for use with optimistic concurrency control.
*
- * @param int $version Document version
- * @return \Elastica\Document Current object
- * @link http://www.elasticsearch.org/blog/2011/02/08/versioning.html
+ * @param int $version Document version
+ *
+ * @return $this
+ *
+ * @link https://www.elastic.co/blog/versioning
*/
public function setVersion($version)
{
@@ -137,7 +144,7 @@ class AbstractUpdateAction extends Param
}
/**
- * Returns document version
+ * Returns document version.
*
* @return string|int Document version
*/
@@ -156,11 +163,11 @@ class AbstractUpdateAction extends Param
/**
* Sets the version_type of a document
- * Default in ES is internal, but you can set to external to use custom versioning
+ * Default in ES is internal, but you can set to external to use custom versioning.
+ *
+ * @param int $versionType Document version type
*
- * @param int $versionType Document version type
- * @return \Elastica\Document Current object
- * @link http://www.elasticsearch.org/guide/reference/api/index_.html
+ * @return $this
*/
public function setVersionType($versionType)
{
@@ -168,7 +175,7 @@ class AbstractUpdateAction extends Param
}
/**
- * Returns document version type
+ * Returns document version type.
*
* @return string|int Document version type
*/
@@ -186,11 +193,13 @@ class AbstractUpdateAction extends Param
}
/**
- * Sets parent document id
+ * Sets parent document id.
+ *
+ * @param string|int $parent Parent document id
+ *
+ * @return $this
*
- * @param string|int $parent Parent document id
- * @return \Elastica\Document Current object
- * @link http://www.elasticsearch.org/guide/reference/mapping/parent-field.html
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-parent-field.html
*/
public function setParent($parent)
{
@@ -198,7 +207,7 @@ class AbstractUpdateAction extends Param
}
/**
- * Returns the parent document id
+ * Returns the parent document id.
*
* @return string|int Parent document id
*/
@@ -216,10 +225,11 @@ class AbstractUpdateAction extends Param
}
/**
- * Set operation type
+ * Set operation type.
*
- * @param string $opType Only accept create
- * @return \Elastica\Document Current object
+ * @param string $opType Only accept create
+ *
+ * @return $this
*/
public function setOpType($opType)
{
@@ -227,7 +237,8 @@ class AbstractUpdateAction extends Param
}
/**
- * Get operation type
+ * Get operation type.
+ *
* @return string
*/
public function getOpType()
@@ -244,10 +255,11 @@ class AbstractUpdateAction extends Param
}
/**
- * Set percolate query param
+ * Set percolate query param.
*
- * @param string $value percolator filter
- * @return \Elastica\Document
+ * @param string $value percolator filter
+ *
+ * @return $this
*/
public function setPercolate($value = '*')
{
@@ -255,7 +267,7 @@ class AbstractUpdateAction extends Param
}
/**
- * Get percolate parameter
+ * Get percolate parameter.
*
* @return string
*/
@@ -273,10 +285,11 @@ class AbstractUpdateAction extends Param
}
/**
- * Set routing query param
+ * Set routing query param.
*
- * @param string $value routing
- * @return \Elastica\Document
+ * @param string $value routing
+ *
+ * @return $this
*/
public function setRouting($value)
{
@@ -284,7 +297,7 @@ class AbstractUpdateAction extends Param
}
/**
- * Get routing parameter
+ * Get routing parameter.
*
* @return string
*/
@@ -303,18 +316,20 @@ class AbstractUpdateAction extends Param
/**
* @param array|string $fields
- * @return \Elastica\Document
+ *
+ * @return $this
*/
public function setFields($fields)
{
if (is_array($fields)) {
$fields = implode(',', $fields);
}
+
return $this->setParam('_fields', (string) $fields);
}
/**
- * @return \Elastica\Document
+ * @return $this
*/
public function setFieldsSource()
{
@@ -339,7 +354,8 @@ class AbstractUpdateAction extends Param
/**
* @param int $num
- * @return \Elastica\Document
+ *
+ * @return $this
*/
public function setRetryOnConflict($num)
{
@@ -364,7 +380,8 @@ class AbstractUpdateAction extends Param
/**
* @param string $timestamp
- * @return \Elastica\Document
+ *
+ * @return $this
*/
public function setTimestamp($timestamp)
{
@@ -389,7 +406,8 @@ class AbstractUpdateAction extends Param
/**
* @param bool $refresh
- * @return \Elastica\Document
+ *
+ * @return $this
*/
public function setRefresh($refresh = true)
{
@@ -414,7 +432,8 @@ class AbstractUpdateAction extends Param
/**
* @param string $timeout
- * @return \Elastica\Document
+ *
+ * @return $this
*/
public function setTimeout($timeout)
{
@@ -439,7 +458,8 @@ class AbstractUpdateAction extends Param
/**
* @param string $timeout
- * @return \Elastica\Document
+ *
+ * @return $this
*/
public function setConsistency($timeout)
{
@@ -464,7 +484,8 @@ class AbstractUpdateAction extends Param
/**
* @param string $timeout
- * @return \Elastica\Document
+ *
+ * @return $this
*/
public function setReplication($timeout)
{
@@ -489,7 +510,8 @@ class AbstractUpdateAction extends Param
/**
* @param \Elastica\Document|array $data
- * @return \Elastica\Document
+ *
+ * @return $this
*/
public function setUpsert($data)
{
@@ -516,8 +538,9 @@ class AbstractUpdateAction extends Param
}
/**
- * @param array $fields if empty array all options will be returned, field names can be either with underscored either without, i.e. _percolate, routing
- * @param bool $withUnderscore should option keys contain underscore prefix
+ * @param array $fields if empty array all options will be returned, field names can be either with underscored either without, i.e. _percolate, routing
+ * @param bool $withUnderscore should option keys contain underscore prefix
+ *
* @return array
*/
public function getOptions(array $fields = array(), $withUnderscore = false)
@@ -525,7 +548,7 @@ class AbstractUpdateAction extends Param
if (!empty($fields)) {
$data = array();
foreach ($fields as $field) {
- $key = '_' . ltrim($field, '_');
+ $key = '_'.ltrim($field, '_');
if ($this->hasParam($key) && '' !== (string) $this->getParam($key)) {
$data[$key] = $this->getParam($key);
}
@@ -539,6 +562,7 @@ class AbstractUpdateAction extends Param
unset($data[$key]);
}
}
+
return $data;
}
-} \ No newline at end of file
+}