PHP Класс Elastica\Index

Handles reads, deletes and configurations of an index
Автор: Nicolas Ruflin ([email protected])
Наследование: implements elastica\SearchableInterface
Показать файл Открыть проект Примеры использования класса

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

Свойство Тип Описание
$_client Client object.
$_name Index name.

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

Метод Описание
__construct ( Client $client, string $name ) Creates a new index object.
addAlias ( string $name, boolean $replace = false ) : Response Adds an alias to the current index.
addDocuments ( array $docs ) : ResponseSet Uses _bulk to send documents to the server.
analyze ( string $text, array $args = [] ) : array Analyzes a string.
clearCache ( ) : Response Clears the cache of an index.
close ( ) : Response Closes the index.
count ( string | array | Query $query = '' ) : integer Counts results of query.
create ( array $args = [], boolean | array $options = null ) : Response Creates a new index with the given arguments.
createSearch ( string | array | Query $query = '', integer | array $options = null, Elastica\ResultSet\BuilderInterface $builder = null ) : Search
delete ( ) : Response Deletes the index.
deleteByQuery ( Query | string | array $query, array $options = [] ) : Response Deletes entries in the db based on a query.
deleteDocuments ( array $docs ) : ResponseSet Uses _bulk to delete documents from the server.
exists ( ) : boolean Checks if the given index is already created.
flush ( $options = [] ) : Response Flushes the index to storage.
forcemerge ( array $args = [] ) : array Force merges index.
getAliases ( ) : array Returns all index aliases.
getClient ( ) : Client Returns index client.
getMapping ( ) : array Gets all the type mappings for an index.
getName ( ) : string Returns the index name.
getSettings ( ) : Settings Returns the index settings object.
getStats ( ) : Stats Return Index Stats.
getType ( string $type ) : Type Returns a type object for the current index with the given name.
hasAlias ( string $name ) : boolean Checks if the index has the given alias.
open ( ) : Response Opens an index.
optimize ( array $args = [] ) : array Optimizes search index.
refresh ( ) : Response Refreshes the index.
removeAlias ( string $name ) : Response Removes an alias pointing to the current index.
request ( string $path, string $method, array | string $data = [], array $query = [] ) : Response Makes calls to the elasticsearch server based on this index.
search ( string | array | Query $query = '', integer | array $options = null ) : ResultSet Searches in this index.
setSettings ( array $data ) : Response Can be used to change settings during runtime. One example is to use it for bulk updating.
updateDocuments ( array $docs ) : ResponseSet Uses _bulk to send documents to the server.

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

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

All the communication to and from an index goes of this object
public __construct ( Client $client, string $name )
$client Client Client object
$name string Index name

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

Adds an alias to the current index.
public addAlias ( string $name, boolean $replace = false ) : Response
$name string Alias name
$replace boolean OPTIONAL If set, an existing alias will be replaced
Результат Response Response

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

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

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

Detailed arguments can be found here in the link
public analyze ( string $text, array $args = [] ) : array
$text string String to be analyzed
$args array OPTIONAL Additional arguments
Результат array Server response

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

Clears the cache of an index.
public clearCache ( ) : Response
Результат Response Response object

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

Closes the index.
public close ( ) : Response
Результат Response Response object

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

Counts results of 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

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

Creates a new index with the given arguments.
public create ( array $args = [], boolean | array $options = null ) : Response
$args array OPTIONAL Arguments to use
$options boolean | array OPTIONAL bool=> Deletes index first if already exists (default = false). array => Associative array of options (option=>value)
Результат Response Server response

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

public createSearch ( string | array | Query $query = '', integer | array $options = null, Elastica\ResultSet\BuilderInterface $builder = null ) : Search
$query string | array | Query
$options integer | array
$builder Elastica\ResultSet\BuilderInterface
Результат Search

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

Deletes the index.
public delete ( ) : Response
Результат Response Response object

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

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

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

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

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

Checks if the given index is already created.
public exists ( ) : boolean
Результат boolean True if index exists

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

Flushes the index to storage.
public flush ( $options = [] ) : Response
Результат Response Response object

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

Detailed arguments can be found here in the link
public forcemerge ( array $args = [] ) : array
$args array OPTIONAL Additional arguments
Результат array Server response

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

Returns all index aliases.
public getAliases ( ) : array
Результат array Aliases

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

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

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

Gets all the type mappings for an index.
public getMapping ( ) : array
Результат array

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

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

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

Returns the index settings object.
public getSettings ( ) : Settings
Результат Elastica\Index\Settings Settings object

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

Return Index Stats.
public getStats ( ) : Stats
Результат Elastica\Index\Stats

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

Returns a type object for the current index with the given name.
public getType ( string $type ) : Type
$type string Type name
Результат Type Type object

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

Checks if the index has the given alias.
public hasAlias ( string $name ) : boolean
$name string Alias name
Результат boolean

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

Opens an index.
public open ( ) : Response
Результат Response Response object

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

Detailed arguments can be found here in the link
Устаревший: Replaced by forcemerge
public optimize ( array $args = [] ) : array
$args array OPTIONAL Additional arguments
Результат array Server response

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

Refreshes the index.
public refresh ( ) : Response
Результат Response Response object

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

Removes an alias pointing to the current index.
public removeAlias ( string $name ) : Response
$name string Alias name
Результат Response Response

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

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

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

Can be used to change settings during runtime. One example is to use it for bulk updating.
public setSettings ( array $data ) : Response
$data array Data array
Результат Response Response object

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

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

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

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

Client object.
protected $_client

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

Index name.
protected $_name