include/SugarSearchEngine/Elastic/Elastica/Document.php

Show: inherited
Table of Contents

Single document stored in elastic search

Author
Nicolas Ruflin  
Category
Xodoa  
Package
Elastica  

\Elastica_Document

Package: Elastica

Single document stored in elastic search

Author
Nicolas Ruflin  
Category
Xodoa  

Properties

Propertyprotectedarray  $_data= 'array()'

Document data
Default valuearray()Details
Type
array
Propertyprotectedstring|int  $_id= ''''

Document id
Default value''Details
Type
string | int
Propertyprotected  $_index= ''''
Default value''Details
Type
n/a
Propertyprotectedstring  $_optype= ''''

Optype
Default value''Details
Type
string
Propertyprotectedstring|int  $_parent= ''''

Parent document id
Default value''Details
Type
string | int
Propertyprotectedstring  $_percolate= ''''

Percolate
Default value''Details
Type
string
Propertyprotected  $_type= ''''
Default value''Details
Type
n/a
Propertyprotected  $_version= ''''
Default value''Details
Type
n/a

Methods

methodpublic__construct( int $id = '', array $data = array(), string $type = '', string $index = '' ) : void

Creates a new document

Parameters
Name Type Description
$id int

OPTIONAL $id Id is create if empty

$data array

OPTIONAL Data array

$type string

OPTIONAL Type name

$index string

OPTIONAL Index name

methodpublicadd( string $key, mixed $value ) : \Elastica_Document

Adds the given key/value pair to the document

Parameters
Name Type Description
$key string

Document entry key

$value mixed

Document entry value

Returns
Type Description
\Elastica_Document
methodpublicaddFile( string $key, string $filepath, string $mimeType = '' ) : \Elastica_Document

Adds a file to the index

To use this feature you have to call the following command in the elasticsearch directory:

./bin/plugin install mapper-attachments

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}

Parameters
Name Type Description
$key string

Key to add the file to

$filepath string

Path to add the file

$mimeType string

OPTIONAL Header mime type

Returns
Type Description
\Elastica_Document
methodpublicaddFileContent( string $key, string $content ) : \Elastica_Document

Parameters
Name Type Description
$key string

Document key

$content string

Raw file content

Returns
Type Description
\Elastica_Document
methodpublicaddGeoPoint( string $key, float $latitude, float $longitude ) : \Elastica_Document

Adds a geopoint to the document

Geohashes re not yet supported

Parameters
Name Type Description
$key string

Field key

$latitude float

Latitud value

$longitude float

Longitude value

Returns
Type Description
\Elastica_Document
Details
Link
http://www.elasticsearch.com/docs/elasticsearch/mapping/geo_point/  
methodpublicgetData( ) : array

Returns the document data

Returns
Type Description
array Document data
methodpublicgetId( ) : string | int

Returns document id

Returns
Type Description
string | int Document id
methodpublicgetIndex( ) : string

Returns
Type Description
string Index name
Throws
Exception Description
\Elastica_Exception_Invalid
methodpublicgetOpType( ) : void

Get operation type

methodpublicgetParent( ) : string | int

Returns the parent document id

Returns
Type Description
string | int Parent document id
methodpublicgetPercolate( ) : string

Get percolate parameter

Returns
Type Description
string
methodpublicgetType( ) : string

Returns
Type Description
string Document type name
Throws
Exception Description
\Elastica_Exception_Invalid
methodpublicgetVersion( ) : string | int

Returns document version

Returns
Type Description
string | int Document version
methodpublicsetData( array $data ) : \Elastica_Document

Overwrites the curent document data with the given data

Parameters
Name Type Description
$data array

Data array

Returns
Type Description
\Elastica_Document
methodpublicsetIndex( string $index ) : \Elastica_Document

Sets the document index name

Parameters
Name Type Description
$index string

Index name

Returns
Type Description
\Elastica_Document Current object
methodpublicsetOpType( string $optype ) : \Elastica_Document

Set operation type

Parameters
Name Type Description
$optype string

Only accept create

Returns
Type Description
\Elastica_Document Current object
methodpublicsetParent( string | int $parent ) : \Elastica_Document

Sets parent document id

Parameters
Name Type Description
$parent string | int

Parent document id

Returns
Type Description
\Elastica_Document Current object
Details
Link
http://www.elasticsearch.org/guide/reference/mapping/parent-field.html  
methodpublicsetPercolate( string $value = '*' ) : \Elastica_Document

Set percolate query param

Parameters
Name Type Description
$value string

percolator filter

Returns
Type Description
\Elastica_Document
methodpublicsetTTL( string $ttl ) : \Elastica_Document

Sets lifetime of document

Parameters
Name Type Description
$ttl string
Returns
Type Description
\Elastica_Document
methodpublicsetType( string $type ) : \Elastica_Document

Sets the document type name

Parameters
Name Type Description
$type string

Type name

Returns
Type Description
\Elastica_Document Current object
methodpublicsetVersion( int $version ) : \Elastica_Document

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

Parameters
Name Type Description
$version int

Document version

Returns
Type Description
\Elastica_Document Current object
Details
Link
http://www.elasticsearch.org/blog/2011/02/08/versioning.html  
methodpublictoArray( ) : array

Returns the document as an array

Returns
Type Description
array
Documentation was generated by DocBlox 0.18.1.