Download the PHP package friendsofcat/opensearch-adapter without Composer
On this page you can find all versions of the php package friendsofcat/opensearch-adapter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download friendsofcat/opensearch-adapter
More information about friendsofcat/opensearch-adapter
Files in friendsofcat/opensearch-adapter
Package opensearch-adapter
Short Description Adapter for official PHP OpenSearch client
License MIT
Informations about the package opensearch-adapter
OpenSearch Adapter
OpenSearch Adapter is an adapter for the official PHP OpenSearch 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 OpenSearch Adapter has been tested with the following configuration:
- PHP 7.4-8.x
- OpenSearch 2.x
- Laravel 6.x-8.x
Installation
The library can be installed via Composer:
Configuration
OpenSearch Adapter uses friendsofcat/opensearch-client
as a dependency.
To change the client settings you need to publish the configuration file first:
In the newly created config/opensearch.client.php
file you can define the default connection name and describe multiple
connections using configuration hashes. Please, refer to
the opensearch-client documentation for more details.
Index Management
\OpenSearch\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 OpenSearch connection:
Document Management
\OpenSearch\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 OpenSearch connection: