PHP Класс Elastica\Type

elasticsearch has for every types as a substructure. This object represents a type inside a context The hierarchy is as following: client -> index -> type -> document
Автор: Nicolas Ruflin ([email protected])
Наследование: implements elastica\SearchableInterface
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$_index Index.
$_name Type name.
$_serializer A callable that serializes an object passed to it

Открытые методы

Метод Описание
__construct ( Index $index, string $name ) Creates a new type object inside the given index.
addDocument ( Document $doc ) : Response Adds the given document to the search index.
addDocuments ( array $docs ) : ResponseSet Uses _bulk to send documents to the server.
addObject ( $object, Document $doc = null ) : Response
addObjects ( array $objects ) : ResponseSet Uses _bulk to send documents to the server.
count ( string | array | Query $query = '' ) : integer Count docs by query.
createDocument ( string $id = '', array | string $data = [] ) : Document
createSearch ( string | array | Query $query = '', integer | array $options = null, Elastica\ResultSet\BuilderInterface $builder = null ) : Search Create search object.
deleteById ( integer | string $id, array $options = [] ) : Response Deletes an entry by its unique identifier.
deleteByQuery ( Query | string $query, array $options = [] ) : Response Deletes entries in the db based on a query.
deleteDocument ( Document $document ) : Response
deleteDocuments ( array $docs ) : ResponseSet Uses _bulk to delete documents from the server.
deleteIds ( array $ids, string | boolean $routing = false ) : Response Deletes the given list of ids from this type.
exists ( ) : boolean Checks if the given type exists in Index.
getDocument ( string $id, array $options = [] ) : Document Get the document from search index.
getIndex ( ) : Index Returns index client.
getMapping ( ) : array Returns current mapping for the given type.
getName ( ) : string Returns the type name.
request ( string $path, string $method, array $data = [], array $query = [] ) : Response Makes calls to the elasticsearch server based on this type.
search ( string | array | Query $query = '', integer | array $options = null ) : ResultSet Do a search on this type.
setMapping ( Mapping | array $mapping ) : Response Sets value type mapping for this type.
setSerializer ( array | string $serializer ) Sets the serializer callable used in addObject.
updateDocument ( Document | Elastica\Script\AbstractScript $data, array $options = [] ) : Response Update document, using update script. Requires elasticsearch >= 0.19.0.
updateDocuments ( array $docs ) : ResponseSet Uses _bulk to send documents to the server.

Описание методов

__construct() публичный Метод

Creates a new type object inside the given index.
public __construct ( Index $index, string $name )
$index Index Index Object
$name string Type name

addDocument() публичный Метод

Adds the given document to the search index.
public addDocument ( Document $doc ) : Response
$doc Document Document with data
Результат Response

addDocuments() публичный Метод

Uses _bulk to send documents to the server.
public addDocuments ( array $docs ) : ResponseSet
$docs array Array of Elastica\Document
Результат Elastica\Bulk\ResponseSet

addObject() публичный Метод

public addObject ( $object, Document $doc = null ) : Response
$object
$doc Document
Результат Response

addObjects() публичный Метод

Uses _bulk to send documents to the server.
public addObjects ( array $objects ) : ResponseSet
$objects array
Результат Elastica\Bulk\ResponseSet

count() публичный Метод

Count docs by query.
См. также: Elastica\SearchableInterface::count
public count ( string | array | Query $query = '' ) : integer
$query string | array | Query Array with all query data inside or a Elastica\Query object
Результат integer number of documents matching the query

createDocument() публичный Метод

public createDocument ( string $id = '', array | string $data = [] ) : Document
$id string
$data array | string
Результат Document

createSearch() публичный Метод

Create search object.
public createSearch ( string | array | Query $query = '', integer | array $options = null, Elastica\ResultSet\BuilderInterface $builder = null ) : Search
$query string | array | Query Array with all query data inside or a Elastica\Query object
$options integer | array OPTIONAL Limit or associative array of options (option=>value)
$builder Elastica\ResultSet\BuilderInterface
Результат Search

deleteById() публичный Метод

Deletes an entry by its unique identifier.
public deleteById ( integer | string $id, array $options = [] ) : Response
$id integer | string Document id
$options array
Результат Response Response object

deleteByQuery() публичный Метод

Deletes entries in the db based on a query.
public deleteByQuery ( Query | string $query, array $options = [] ) : Response
$query Query | string Query object
$options array Optional params
Результат Response

deleteDocument() публичный Метод

public deleteDocument ( Document $document ) : Response
$document Document
Результат Response

deleteDocuments() публичный Метод

Uses _bulk to delete documents from the server.
public deleteDocuments ( array $docs ) : ResponseSet
$docs array Array of Elastica\Document
Результат Elastica\Bulk\ResponseSet

deleteIds() публичный Метод

Deletes the given list of ids from this type.
public deleteIds ( array $ids, string | boolean $routing = false ) : Response
$ids array
$routing string | boolean Optional routing key for all ids
Результат Response Response object

exists() публичный Метод

Checks if the given type exists in Index.
public exists ( ) : boolean
Результат boolean True if type exists

getDocument() публичный Метод

Get the document from search index.
public getDocument ( string $id, array $options = [] ) : Document
$id string Document id
$options array Options for the get request.
Результат Document

getIndex() публичный Метод

Returns index client.
public getIndex ( ) : Index
Результат Index Index object

getMapping() публичный Метод

Returns current mapping for the given type.
public getMapping ( ) : array
Результат array Current mapping

getName() публичный Метод

Returns the type name.
public getName ( ) : string
Результат string Type name

request() публичный Метод

Makes calls to the elasticsearch server based on this type.
public request ( string $path, string $method, array $data = [], array $query = [] ) : Response
$path string Path to call
$method string Rest method to use (GET, POST, DELETE, PUT)
$data array OPTIONAL Arguments as array
$query array OPTIONAL Query params
Результат Response Response object

setMapping() публичный Метод

Sets value type mapping for this type.
public setMapping ( Mapping | array $mapping ) : Response
$mapping Elastica\Type\Mapping | array Elastica\Type\MappingType object or property array with all mappings
Результат Response

setSerializer() публичный Метод

Sets the serializer callable used in addObject.
См. также: Elastica\Type::addObject
public setSerializer ( array | string $serializer )
$serializer array | string @see \Elastica\Type::_serializer

updateDocument() публичный Метод

Update document, using update script. Requires elasticsearch >= 0.19.0.
public updateDocument ( Document | Elastica\Script\AbstractScript $data, array $options = [] ) : Response
$data Document | Elastica\Script\AbstractScript Document with update data
$options array array of query params to use for query. For possible options check es api
Результат Response

updateDocuments() публичный Метод

Uses _bulk to send documents to the server.
public updateDocuments ( array $docs ) : ResponseSet
$docs array Array of Elastica\Document
Результат Elastica\Bulk\ResponseSet

Описание свойств

$_index защищенное свойство

Index.
protected $_index

$_name защищенное свойство

Type name.
protected $_name

$_serializer защищенное свойство

A callable that serializes an object passed to it
protected $_serializer