include/SugarSearchEngine/Elastic/Elastica/Document.php
Single document stored in elastic search
- Author
- Nicolas Ruflin
- Category
- Xodoa
- Package
- Elastica
\Elastica_Document
Single document stored in elastic search
- Author
- Nicolas Ruflin
- Category
- Xodoa
Properties
Methods

__construct(
int $id
=
'', array $data
=
array(), string $type
=
'', string $index
=
''
)
:
voidCreates a new document
| 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 |

add(
string $key, mixed $value
)
:
\Elastica_DocumentAdds the given key/value pair to the document
| Name | Type | Description |
|---|---|---|
| $key | string | Document entry key |
| $value | mixed | Document entry value |
| Type | Description |
|---|---|
| \Elastica_Document |

addFile(
string $key, string $filepath, string $mimeType
=
''
)
:
\Elastica_DocumentAdds 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}
| Name | Type | Description |
|---|---|---|
| $key | string | Key to add the file to |
| $filepath | string | Path to add the file |
| $mimeType | string | OPTIONAL Header mime type |
| Type | Description |
|---|---|
| \Elastica_Document |

addFileContent(
string $key, string $content
)
:
\Elastica_Document| Name | Type | Description |
|---|---|---|
| $key | string | Document key |
| $content | string | Raw file content |
| Type | Description |
|---|---|
| \Elastica_Document |

addGeoPoint(
string $key, float $latitude, float $longitude
)
:
\Elastica_DocumentAdds a geopoint to the document
Geohashes re not yet supported
| Name | Type | Description |
|---|---|---|
| $key | string | Field key |
| $latitude | float | Latitud value |
| $longitude | float | Longitude value |
| Type | Description |
|---|---|
| \Elastica_Document |

getIndex(
)
:
string| Type | Description |
|---|---|
| string | Index name |
| Exception | Description |
|---|---|
| \Elastica_Exception_Invalid |

getParent(
)
:
string | intReturns the parent document id
| Type | Description |
|---|---|
| string | int | Parent document id |

getType(
)
:
string| Type | Description |
|---|---|
| string | Document type name |
| Exception | Description |
|---|---|
| \Elastica_Exception_Invalid |

getVersion(
)
:
string | intReturns document version
| Type | Description |
|---|---|
| string | int | Document version |

setData(
array $data
)
:
\Elastica_DocumentOverwrites the curent document data with the given data
| Name | Type | Description |
|---|---|---|
| $data | array | Data array |
| Type | Description |
|---|---|
| \Elastica_Document |

setIndex(
string $index
)
:
\Elastica_DocumentSets the document index name
| Name | Type | Description |
|---|---|---|
| $index | string | Index name |
| Type | Description |
|---|---|
| \Elastica_Document | Current object |

setOpType(
string $optype
)
:
\Elastica_DocumentSet operation type
| Name | Type | Description |
|---|---|---|
| $optype | string | Only accept create |
| Type | Description |
|---|---|
| \Elastica_Document | Current object |

setParent(
string | int $parent
)
:
\Elastica_DocumentSets parent document id
| Name | Type | Description |
|---|---|---|
| $parent | string | int | Parent document id |
| Type | Description |
|---|---|
| \Elastica_Document | Current object |

setPercolate(
string $value
=
'*'
)
:
\Elastica_DocumentSet percolate query param
| Name | Type | Description |
|---|---|---|
| $value | string | percolator filter |
| Type | Description |
|---|---|
| \Elastica_Document |

setTTL(
string $ttl
)
:
\Elastica_DocumentSets lifetime of document
| Name | Type | Description |
|---|---|---|
| $ttl | string |
| Type | Description |
|---|---|
| \Elastica_Document |

setType(
string $type
)
:
\Elastica_DocumentSets the document type name
| Name | Type | Description |
|---|---|---|
| $type | string | Type name |
| Type | Description |
|---|---|
| \Elastica_Document | Current object |

setVersion(
int $version
)
:
\Elastica_DocumentSets the version of a document for use with optimistic concurrency control
| Name | Type | Description |
|---|---|---|
| $version | int | Document version |
| Type | Description |
|---|---|
| \Elastica_Document | Current object |