Download the PHP package babenkoivan/elastic-adapter without Composer
On this page you can find all versions of the php package babenkoivan/elastic-adapter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download babenkoivan/elastic-adapter
More information about babenkoivan/elastic-adapter
Files in babenkoivan/elastic-adapter
Package elastic-adapter
Short Description Adapter for official PHP Elasticsearch client
License MIT
Informations about the package elastic-adapter
Elastic Adapter
Elastic Adapter is an adapter for the official PHP Elasticsearch client. It's designed to simplify basic index and document operations.
Contents
- Compatibility
- Installation
- Configuration
- Index Management
- Document Management
- Point in Time Management
Compatibility
The current version of Elastic Adapter has been tested with the following configuration:
- PHP 8.2
- Elasticsearch 8.x
- Laravel 11.x
If your project uses older Laravel (or PHP) version check the previous major version of the package.
Installation
The library can be installed via Composer:
Configuration
Elastic Adapter uses babenkoivan/elastic-client as a dependency. To change the client settings you need to publish the configuration file first:
In the newly created config/elastic.client.php
file you can define the default connection name and describe multiple
connections using configuration hashes. Please, refer to
the elastic-client documentation for more details.
Index Management
\Elastic\Adapter\Indices\IndexManager
is used to manipulate indices.
Create
Create an index, either with the default settings and mapping:
or configured according to your needs:
Alternatively, you can create an index using raw input:
Drop
Delete an index:
Put Mapping
Update an index mapping using builder:
or using raw input:
Put Settings
Update an index settings using builder:
or using raw input:
Exists
Check if an index exists:
Open
Open an index:
Close
Close an index:
Put Alias
Create an alias:
The same with raw input:
Get Aliases
Get index aliases:
Delete Alias
Delete an alias:
Connection
Switch Elasticsearch connection:
Document Management
\Elastic\Adapter\Documents\DocumentManager
is used to manage and search documents.
Index
Add a document to the index:
There is also an option to refresh index immediately:
Finally, you can set a custom routing:
Delete
Remove a document from the index:
If you want the index to be refreshed immediately pass true
as the third argument:
You can also set a custom routing:
Finally, you can delete documents using query:
Search
Search documents in the index:
Connection
Switch Elasticsearch connection:
Point in Time Management
\Elastic\Adapter\Search\PointInTimeManager
is used to control points in time.
Open
Open a point in time:
Close
Close a point in time:
Connection
Switch Elasticsearch connection: