Download the PHP package iivannov/elastic-commander without Composer
On this page you can find all versions of the php package iivannov/elastic-commander. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download iivannov/elastic-commander
More information about iivannov/elastic-commander
Files in iivannov/elastic-commander
Package elastic-commander
Short Description Wrapper for the official Elasticsearch PHP Client
License MIT
Informations about the package elastic-commander
Elastic Commander
This a simple and easy to use wrapper for the official low-level Elasticsearch PHP Client.
It simplifies the work with Elasticsearch API by offering a lot of helper methods for managing indices, adding and updating documents and searching the index.
Installation
Via Composer
Usage
Initialization
Minimum required (will work with default host - localhost:9200)
With a list of hosts
With a custom handler
N.B. Each instance of the Commander works with the index name specified when initializing it. All actions and queries will be executed on this index. If you want to set a new index name to work with use:
Index
1. Create the index
2. Delete the index
3. Reset the index
A helper method that will reset the index by deleting it and creating it again.
4. Optimize the index
// Not finished
5. Statistics about the index
// Not finished
Mapping
1. Put Mapping
Document
1. Check if document exists by id
2. Get document by id
3. Add document
In current version the add method expects an ID for the document.
4. Update document
Search
Searching is done by passing a raw query array or by using a custom criteria class. After the query you have the option to get: the full response, only the ids, a map of the results or the total count.
1. Raw Query
2. Criteria Query
Result
After running either a raw query or one with a criteria class you can use one of the helper methods for manipulating the result response.
1. Return ElasticSearch raw response
2. Return total number of results
3. Return an array of IDs for the found hits
3. Return an array of objects for the found hits
The key will be the _id of the hit and the value will be an stdClass of the _source
Count
// Not finished