PHP Class Elastica\Document

Author: Nicolas Ruflin ([email protected])
Inheritance: extends AbstractUpdateAction
Datei anzeigen Open project: ruflin/elastica Class Usage Examples

Protected Properties

Property Type Description
$_autoPopulate boolean
$_data Document data.
$_docAsUpsert boolean Whether to use this document to upsert if the document does not exist.

Public Methods

Method Description
__construct ( integer | string $id = '', array | string $data = [], Type | string $type = '', Index | string $index = '' ) Creates a new document.
__get ( string $key ) : mixed
__isset ( string $key ) : boolean
__set ( string $key, mixed $value )
__unset ( string $key )
addFile ( string $key, string $filepath, string $mimeType = '' ) Adds a file to the index.
addFileContent ( string $key, string $content ) Add file content.
addGeoPoint ( string $key, float $latitude, float $longitude ) Adds a geopoint to the document.
create ( array | Document $data ) : self
get ( string $key ) : mixed
getData ( ) : array | string Returns the document data.
getDocAsUpsert ( ) : boolean
has ( string $key ) : boolean
isAutoPopulate ( ) : boolean
remove ( string $key )
set ( string $key, mixed $value )
setAutoPopulate ( boolean $autoPopulate = true )
setData ( array | string $data ) Overwrites the current document data with the given data.
setDocAsUpsert ( boolean $value )
toArray ( ) : array Returns the document as an array.

Method Details

__construct() public method

Creates a new document.
public __construct ( integer | string $id = '', array | string $data = [], Type | string $type = '', Index | string $index = '' )
$id integer | string OPTIONAL $id Id is create if empty
$data array | string OPTIONAL Data array
$type Type | string OPTIONAL Type name
$index Index | string OPTIONAL Index name

__get() public method

public __get ( string $key ) : mixed
$key string
return mixed

__isset() public method

public __isset ( string $key ) : boolean
$key string
return boolean

__set() public method

public __set ( string $key, mixed $value )
$key string
$value mixed

__unset() public method

public __unset ( string $key )
$key string

addFile() public method

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: {@link http://tika.apache.org/0.7/formats.html}
public addFile ( string $key, string $filepath, string $mimeType = '' )
$key string Key to add the file to
$filepath string Path to add the file
$mimeType string OPTIONAL Header mime type

addFileContent() public method

Add file content.
public addFileContent ( string $key, string $content )
$key string Document key
$content string Raw file content

addGeoPoint() public method

Geohashes are not yet supported
public addGeoPoint ( string $key, float $latitude, float $longitude )
$key string Field key
$latitude float Latitude value
$longitude float Longitude value

create() public static method

public static create ( array | Document $data ) : self
$data array | Document
return self

get() public method

public get ( string $key ) : mixed
$key string
return mixed

getData() public method

Returns the document data.
public getData ( ) : array | string
return array | string Document data

getDocAsUpsert() public method

public getDocAsUpsert ( ) : boolean
return boolean

has() public method

public has ( string $key ) : boolean
$key string
return boolean

isAutoPopulate() public method

public isAutoPopulate ( ) : boolean
return boolean

remove() public method

public remove ( string $key )
$key string

set() public method

public set ( string $key, mixed $value )
$key string
$value mixed

setAutoPopulate() public method

public setAutoPopulate ( boolean $autoPopulate = true )
$autoPopulate boolean

setData() public method

Overwrites the current document data with the given data.
public setData ( array | string $data )
$data array | string Data array

setDocAsUpsert() public method

public setDocAsUpsert ( boolean $value )
$value boolean

toArray() public method

Returns the document as an array.
public toArray ( ) : array
return array

Property Details

$_autoPopulate protected_oe property

protected bool $_autoPopulate
return boolean

$_data protected_oe property

Document data.
protected $_data

$_docAsUpsert protected_oe property

Whether to use this document to upsert if the document does not exist.
protected bool $_docAsUpsert
return boolean