Constants

OP_TYPE_CREATE

OP_TYPE_CREATE

Properties

$_params

$_params : array

Params.

Type

array

$_rawParams

$_rawParams : array

Raw Params.

Type

array

$_data

$_data : array

Document data.

Type

array — Document data

$_docAsUpsert

$_docAsUpsert : boolean

Whether to use this document to upsert if the document does not exist.

Type

boolean

$_autoPopulate

$_autoPopulate : boolean

Type

boolean

Methods

setId()

setId(string  $id) : $this

Sets the id of the document.

Parameters

string $id

Returns

$this

getId()

getId() : string|integer

Returns document id.

Returns

string|integer —

Document id

hasId()

hasId() : boolean

Returns

boolean

setTtl()

setTtl(string  $ttl) : $this

Sets lifetime of document.

Parameters

string $ttl

Returns

$this

getTtl()

getTtl() : string

Returns

string

hasTtl()

hasTtl() : boolean

Returns

boolean

setType()

setType(\Elastica\Type|string  $type) : $this

Sets the document type name.

Parameters

\Elastica\Type|string $type

Type name

Returns

$this

getType()

getType() : string

Return document type name.

Throws

\Elastica\Exception\InvalidException

Returns

string —

Document type name

setIndex()

setIndex(\Elastica\Index|string  $index) : $this

Sets the document index name.

Parameters

\Elastica\Index|string $index

Index name

Returns

$this

getIndex()

getIndex() : string

Get the document index name.

Throws

\Elastica\Exception\InvalidException

Returns

string —

Index name

setVersion()

setVersion(integer  $version) : $this

Sets the version of a document for use with optimistic concurrency control.

Parameters

integer $version

Document version

Returns

$this

getVersion()

getVersion() : string|integer

Returns document version.

Returns

string|integer —

Document version

hasVersion()

hasVersion() : boolean

Returns

boolean

setVersionType()

setVersionType(string  $versionType) : $this

Sets the version_type of a document Default in ES is internal, but you can set to external to use custom versioning.

Parameters

string $versionType

Document version type

Returns

$this

getVersionType()

getVersionType() : string|integer

Returns document version type.

Returns

string|integer —

Document version type

hasVersionType()

hasVersionType() : boolean

Returns

boolean

setParent()

setParent(string|integer  $parent) : $this

Sets parent document id.

Parameters

string|integer $parent

Parent document id

Returns

$this

getParent()

getParent() : string|integer

Returns the parent document id.

Returns

string|integer —

Parent document id

hasParent()

hasParent() : boolean

Returns

boolean

setOpType()

setOpType(string  $opType) : $this

Set operation type.

Parameters

string $opType

Only accept create

Returns

$this

getOpType()

getOpType() : string

Get operation type.

Returns

string

hasOpType()

hasOpType() : boolean

Returns

boolean

setPercolate()

setPercolate(string  $value = '*') : $this

Set percolate query param.

Parameters

string $value

percolator filter

Returns

$this

getPercolate()

getPercolate() : string

Get percolate parameter.

Returns

string

hasPercolate()

hasPercolate() : boolean

Returns

boolean

setRouting()

setRouting(string  $value) : $this

Set routing query param.

Parameters

string $value

routing

Returns

$this

getRouting()

getRouting() : string

Get routing parameter.

Returns

string

hasRouting()

hasRouting() : boolean

Returns

boolean

setFields()

setFields(array|string  $fields) : $this

Parameters

array|string $fields

Returns

$this

setFieldsSource()

setFieldsSource() : $this

Returns

$this

getFields()

getFields() : string

Returns

string

hasFields()

hasFields() : boolean

Returns

boolean

setRetryOnConflict()

setRetryOnConflict(integer  $num) : $this

Parameters

integer $num

Returns

$this

getRetryOnConflict()

getRetryOnConflict() : integer

Returns

integer

hasRetryOnConflict()

hasRetryOnConflict() : boolean

Returns

boolean

setTimestamp()

setTimestamp(string  $timestamp) : $this

Parameters

string $timestamp

Returns

$this

getTimestamp()

getTimestamp() : integer

Returns

integer

hasTimestamp()

hasTimestamp() : boolean

Returns

boolean

setRefresh()

setRefresh(boolean  $refresh = true) : $this

Parameters

boolean $refresh

Returns

$this

getRefresh()

getRefresh() : boolean

Returns

boolean

hasRefresh()

hasRefresh() : boolean

Returns

boolean

setTimeout()

setTimeout(string  $timeout) : $this

Parameters

string $timeout

Returns

$this

getTimeout()

getTimeout() : boolean

Returns

boolean

hasTimeout()

hasTimeout() : boolean

Returns

boolean

setConsistency()

setConsistency(string  $timeout) : $this

Parameters

string $timeout

Returns

$this

getConsistency()

getConsistency() : string

Returns

string

hasConsistency()

hasConsistency() : boolean

Returns

boolean

setReplication()

setReplication(string  $timeout) : $this

Parameters

string $timeout

Returns

$this

getReplication()

getReplication() : string

Returns

string

hasReplication()

hasReplication() : boolean

Returns

boolean

setUpsert()

setUpsert(\Elastica\Document|array  $data) : $this

Parameters

\Elastica\Document|array $data

Returns

$this

hasUpsert()

hasUpsert() : boolean

Returns

boolean

getOptions()

getOptions(array  $fields = array(), boolean  $withUnderscore = false) : array

Parameters

array $fields

if empty array all options will be returned, field names can be either with underscored either without, i.e. _percolate, routing

boolean $withUnderscore

should option keys contain underscore prefix

Returns

array

toArray()

toArray() : array

Returns the document as an array.

Returns

array

setParam()

setParam(string  $key, mixed  $value) : $this

Sets (overwrites) the value at the given key.

Parameters

string $key

Key to set

mixed $value

Key Value

Returns

$this

setParams()

setParams(array  $params) : $this

Sets (overwrites) all params of this object.

Parameters

array $params

Parameter list

Returns

$this

addParam()

addParam(string  $key, mixed  $value) : $this

Adds a param to the list.

This function can be used to add an array of params

Parameters

string $key

Param key

mixed $value

Value to set

Returns

$this

getParam()

getParam(string  $key) : mixed

Returns a specific param.

Parameters

string $key

Key to return

Throws

\Elastica\Exception\InvalidException

If requested key is not set

Returns

mixed —

Key value

hasParam()

hasParam(string  $key) : boolean

Test if a param is set.

Parameters

string $key

Key to test

Returns

boolean —

True if the param is set, false otherwise

getParams()

getParams() : array

Returns the params array.

Returns

array —

Params

__construct()

__construct(integer|string  $id = '', array|string  $data = array(), \Elastica\Type|string  $type = '', \Elastica\Index|string  $index = '') 

Creates a new document.

Parameters

integer|string $id

OPTIONAL $id Id is create if empty

array|string $data

OPTIONAL Data array

\Elastica\Type|string $type

OPTIONAL Type name

\Elastica\Index|string $index

OPTIONAL Index name

__get()

__get(string  $key) : mixed

Parameters

string $key

Returns

mixed

__set()

__set(string  $key, mixed  $value) 

Parameters

string $key
mixed $value

__isset()

__isset(string  $key) : boolean

Parameters

string $key

Returns

boolean

__unset()

__unset(string  $key) 

Parameters

string $key

get()

get(string  $key) : mixed

Parameters

string $key

Throws

\Elastica\Exception\InvalidException

Returns

mixed

set()

set(string  $key, mixed  $value) : $this

Parameters

string $key
mixed $value

Throws

\Elastica\Exception\InvalidException

Returns

$this

has()

has(string  $key) : boolean

Parameters

string $key

Returns

boolean

remove()

remove(string  $key) : $this

Parameters

string $key

Throws

\Elastica\Exception\InvalidException

Returns

$this

add()

add(string  $key, mixed  $value) : $this

Adds the given key/value pair to the document.

Parameters

string $key

Document entry key

mixed $value

Document entry value

Returns

$this

addFile()

addFile(string  $key, string  $filepath, string  $mimeType = '') : $this

Adds a file to the index.

To use this feature you have to call the following command in the elasticsearch directory: ./bin/plugin -install elasticsearch/elasticsearch-mapper-attachments/1.6.0 This installs the tika file analysis plugin. More infos about supported formats can be found here: http://tika.apache.org/0.7/formats.html

Parameters

string $key

Key to add the file to

string $filepath

Path to add the file

string $mimeType

OPTIONAL Header mime type

Returns

$this

addFileContent()

addFileContent(string  $key, string  $content) : $this

Add file content.

Parameters

string $key

Document key

string $content

Raw file content

Returns

$this

addGeoPoint()

addGeoPoint(string  $key, float  $latitude, float  $longitude) : $this

Adds a geopoint to the document.

Geohashes are not yet supported

Parameters

string $key

Field key

float $latitude

Latitude value

float $longitude

Longitude value

Returns

$this

setData()

setData(array|string  $data) : $this

Overwrites the current document data with the given data.

Parameters

array|string $data

Data array

Returns

$this

getData()

getData() : array|string

Returns the document data.

Returns

array|string —

Document data

setScript()

setScript(\Elastica\Script\Script  $data) 

Parameters

\Elastica\Script\Script $data

Throws

\Elastica\Exception\NotImplementedException

getScript()

getScript() 

Throws

\Elastica\Exception\NotImplementedException

hasScript()

hasScript() 

Throws

\Elastica\Exception\NotImplementedException

setDocAsUpsert()

setDocAsUpsert(boolean  $value) : $this

Parameters

boolean $value

Returns

$this

getDocAsUpsert()

getDocAsUpsert() : boolean

Returns

boolean

setAutoPopulate()

setAutoPopulate(boolean  $autoPopulate = true) : $this

Parameters

boolean $autoPopulate

Returns

$this

isAutoPopulate()

isAutoPopulate() : boolean

Returns

boolean

create()

create(array|\Elastica\Document  $data) : self

Parameters

array|\Elastica\Document $data

Throws

\Elastica\Exception\InvalidException

Returns

self

_convertArrayable()

_convertArrayable(array  $array) : array

Cast objects to arrays.

Parameters

array $array

Returns

array

_getBaseName()

_getBaseName() : string

Param's name Picks the last part of the class name and makes it snake_case You can override this method if you want to change the name.

Returns

string —

name

_setRawParam()

_setRawParam(string  $key, mixed  $value) : $this

Sets params not inside params array.

Parameters

string $key
mixed $value

Returns

$this