$_name
$_name : string
Index name.
Elastica index object.
Handles reads, deletes and configurations of an index
$_client : \Elastica\Client
Client object.
__construct(\Elastica\Client $client, string $name)
Creates a new index object.
All the communication to and from an index goes of this object
\Elastica\Client | $client | Client object |
string | $name | Index name |
getType(string $type) : \Elastica\Type
Returns a type object for the current index with the given name.
string | $type | Type name |
Type object
getStats() : \Elastica\Index\Stats
Return Index Stats.
getSettings() : \Elastica\Index\Settings
Returns the index settings object.
Settings object
updateDocuments(array|array<mixed,\Elastica\Document> $docs) : \Elastica\Bulk\ResponseSet
Uses _bulk to send documents to the server.
array|array<mixed,\Elastica\Document> | $docs | Array of Elastica\Document |
addDocuments(array|array<mixed,\Elastica\Document> $docs) : \Elastica\Bulk\ResponseSet
Uses _bulk to send documents to the server.
array|array<mixed,\Elastica\Document> | $docs | Array of Elastica\Document |
deleteByQuery(\Elastica\Query|string|array $query, array $options = array()) : \Elastica\Response
Deletes entries in the db based on a query.
\Elastica\Query|string|array | $query | Query object or array |
array | $options | Optional params |
delete() : \Elastica\Response
Deletes the index.
Response object
deleteDocuments(array|array<mixed,\Elastica\Document> $docs) : \Elastica\Bulk\ResponseSet
Uses _bulk to delete documents from the server.
array|array<mixed,\Elastica\Document> | $docs | Array of Elastica\Document |
optimize(array $args = array()) : \Elastica\Response
Optimizes search index.
Detailed arguments can be found here in the link
array | $args | OPTIONAL Additional arguments |
Server response
refresh() : \Elastica\Response
Refreshes the index.
Response object
create(array $args = array(), boolean|array $options = null) : \Elastica\Response
Creates a new index with the given arguments.
array | $args | OPTIONAL Arguments to use |
boolean|array | $options | OPTIONAL bool=> Deletes index first if already exists (default = false). array => Associative array of options (option=>value) |
Server response
createSearch(string|array|\Elastica\Query $query = '', integer|array $options = null, \Elastica\ResultSet\BuilderInterface $builder = null) : \Elastica\Search
string|array|\Elastica\Query | $query | |
integer|array | $options | |
\Elastica\ResultSet\BuilderInterface | $builder |
search(string|array|\Elastica\Query $query = '', integer|array $options = null) : \Elastica\ResultSet
Searches in this index.
TODO: Improve sample code { "from" : 0, "size" : 10, "sort" : { "postDate" : {"reverse" : true}, "user" : { }, "_score" : { } }, "query" : { "term" : { "user" : "kimchy" } } }
string|array|\Elastica\Query | $query | Array with all query data inside or a Elastica\Query object |
integer|array | $options | OPTIONAL Limit or associative array of options (option=>value) |
with all results inside
count(string|array|\Elastica\Query $query = '') : integer
Counts results of query.
If no query is set, matchall query is created
string|array|\Elastica\Query | $query | Array with all query data inside or a Elastica\Query object |
number of documents matching the query
open() : \Elastica\Response
Opens an index.
Response object
close() : \Elastica\Response
Closes the index.
Response object
getClient() : \Elastica\Client
Returns index client.
Index client object
addAlias(string $name, boolean $replace = false) : \Elastica\Response
Adds an alias to the current index.
string | $name | Alias name |
boolean | $replace | OPTIONAL If set, an existing alias will be replaced |
Response
removeAlias(string $name) : \Elastica\Response
Removes an alias pointing to the current index.
string | $name | Alias name |
Response
clearCache() : \Elastica\Response
Clears the cache of an index.
Response object
flush(boolean $refresh = false) : \Elastica\Response
Flushes the index to storage.
boolean | $refresh |
Response object
setSettings(array $data) : \Elastica\Response
Can be used to change settings during runtime. One example is to use it for bulk updating.
array | $data | Data array |
Response object
request(string $path, string $method, array|string $data = array(), array $query = array()) : \Elastica\Response
Makes calls to the elasticsearch server based on this index.
string | $path | Path to call |
string | $method | Rest method to use (GET, POST, DELETE, PUT) |
array|string | $data | OPTIONAL Arguments as array or encoded string |
array | $query | OPTIONAL Query params |
Response object