PHP Class Elastica\Index

Handles reads, deletes and configurations of an index
Author: Nicolas Ruflin ([email protected])
Inheritance: implements elastica\SearchableInterface
Afficher le fichier Open project: ruflin/elastica Class Usage Examples

Protected Properties

Свойство Type Description
$_client Client object.
$_name Index name.

Méthodes publiques

Méthode Description
__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.

Method Details

__construct() public méthode

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() public méthode

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
Résultat Response Response

addDocuments() public méthode

Uses _bulk to send documents to the server.
public addDocuments ( array $docs ) : ResponseSet
$docs array Array of Elastica\Document
Résultat Elastica\Bulk\ResponseSet

analyze() public méthode

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
Résultat array Server response

clearCache() public méthode

Clears the cache of an index.
public clearCache ( ) : Response
Résultat Response Response object

close() public méthode

Closes the index.
public close ( ) : Response
Résultat Response Response object

count() public méthode

Counts results of query.
See also: 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
Résultat integer number of documents matching the query

create() public méthode

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)
Résultat Response Server response

createSearch() public méthode

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
Résultat Search

delete() public méthode

Deletes the index.
public delete ( ) : Response
Résultat Response Response object

deleteByQuery() public méthode

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
Résultat Response

deleteDocuments() public méthode

Uses _bulk to delete documents from the server.
public deleteDocuments ( array $docs ) : ResponseSet
$docs array Array of Elastica\Document
Résultat Elastica\Bulk\ResponseSet

exists() public méthode

Checks if the given index is already created.
public exists ( ) : boolean
Résultat boolean True if index exists

flush() public méthode

Flushes the index to storage.
public flush ( $options = [] ) : Response
Résultat Response Response object

forcemerge() public méthode

Detailed arguments can be found here in the link
public forcemerge ( array $args = [] ) : array
$args array OPTIONAL Additional arguments
Résultat array Server response

getAliases() public méthode

Returns all index aliases.
public getAliases ( ) : array
Résultat array Aliases

getClient() public méthode

Returns index client.
public getClient ( ) : Client
Résultat Client Index client object

getMapping() public méthode

Gets all the type mappings for an index.
public getMapping ( ) : array
Résultat array

getName() public méthode

Returns the index name.
public getName ( ) : string
Résultat string Index name

getSettings() public méthode

Returns the index settings object.
public getSettings ( ) : Settings
Résultat Elastica\Index\Settings Settings object

getStats() public méthode

Return Index Stats.
public getStats ( ) : Stats
Résultat Elastica\Index\Stats

getType() public méthode

Returns a type object for the current index with the given name.
public getType ( string $type ) : Type
$type string Type name
Résultat Type Type object

hasAlias() public méthode

Checks if the index has the given alias.
public hasAlias ( string $name ) : boolean
$name string Alias name
Résultat boolean

open() public méthode

Opens an index.
public open ( ) : Response
Résultat Response Response object

optimize() public méthode

Detailed arguments can be found here in the link
public optimize ( array $args = [] ) : array
$args array OPTIONAL Additional arguments
Résultat array Server response

refresh() public méthode

Refreshes the index.
public refresh ( ) : Response
Résultat Response Response object

removeAlias() public méthode

Removes an alias pointing to the current index.
public removeAlias ( string $name ) : Response
$name string Alias name
Résultat Response Response

request() public méthode

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
Résultat Response Response object

setSettings() public méthode

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
Résultat Response Response object

updateDocuments() public méthode

Uses _bulk to send documents to the server.
public updateDocuments ( array $docs ) : ResponseSet
$docs array Array of Elastica\Document
Résultat Elastica\Bulk\ResponseSet

Property Details

$_client protected_oe property

Client object.
protected $_client

$_name protected_oe property

Index name.
protected $_name