Download the PHP package codeartmk/opensearch-laravel without Composer
On this page you can find all versions of the php package codeartmk/opensearch-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download codeartmk/opensearch-laravel
More information about codeartmk/opensearch-laravel
Files in codeartmk/opensearch-laravel
Package opensearch-laravel
Short Description This package integrates the Opensearch client to work seamlessly with your Laravel Eloquent Model.
License MIT
Informations about the package opensearch-laravel
Build Opensearch Queries through Eloquent
Overview
This package integrates the Opensearch client to work seamlessly with your Laravel Eloquent Model.
Installation
To install the Laravel OpenSearch Plugin, use Composer:
and then export the configuration with
Basic usage
Setting up the model
Your models will need to implement the Codeart\OpensearchLaravel\OpenSearchable
interface, and include the trait
Codeart\OpensearchLaravel\Traits\HasOpenSearchDocuments
.
You can override the 3 functions openSearchMapping
, openSearchArray
, and openSearchIndexName
to customize your
mapping, the information stored and the index name.
For mapping options look at OpenSearch mapping documentation.
Building queries and aggregations
Once the model is ready you can start building your queries and aggregation through the opensearch
method on the class:
Supported Query DSL queries:
Match
https://opensearch.org/docs/latest/query-dsl/full-text/match/
Exists
https://opensearch.org/docs/latest/query-dsl/term/exists/
Fuzzy
https://opensearch.org/docs/latest/query-dsl/term/fuzzy/
IDs
https://opensearch.org/docs/latest/query-dsl/term/ids/
Prefix
https://opensearch.org/docs/latest/query-dsl/term/prefix/
Range
https://opensearch.org/docs/latest/query-dsl/term/range/
Regexp
https://opensearch.org/docs/latest/query-dsl/term/regexp/
Wildcard
https://opensearch.org/docs/latest/query-dsl/term/wildcard/
Match All
https://opensearch.org/docs/latest/query-dsl/match-all/
Match Phrase Prefix
https://opensearch.org/docs/latest/query-dsl/full-text/match-phrase-prefix/
Term
https://opensearch.org/docs/latest/query-dsl/term/term/
Supported Aggregations
Average
https://opensearch.org/docs/latest/aggregations/metric/average/
Cardinality
https://opensearch.org/docs/latest/aggregations/metric/cardinality/
Maximum
https://opensearch.org/docs/latest/aggregations/metric/maximum/
Minimum
https://opensearch.org/docs/latest/aggregations/metric/minimum/
Percentile
https://opensearch.org/docs/latest/aggregations/metric/percentile/
Stats
https://opensearch.org/docs/latest/aggregations/metric/stats/
Sum
https://opensearch.org/docs/latest/aggregations/metric/sum/
Terms
https://opensearch.org/docs/latest/aggregations/bucket/terms/
Bucket Sort
https://opensearch.org/docs/latest/aggregations/pipeline-agg/#bucket_sort
We plan to support more in the feature.
Working with indices and documents
We offer tools to help you work with Opensearch indices and documents.
Indices
We have the methods create
, exists
, and delete
currently.
The optional $configuration
parameter in the create
method allows you to customize your
settings
for your index.
Documents
Lazy Loading Relationship
The methods createAll
, create
, and createOrUpdate
all accept a function as a second parameter to allow you to lazy
load your relationship when creating documents.
Extending the functionality
If we've missed a search query you need or an aggregation you need, you can easily implement your own and integrate it to work our core functionality.
Search Query
Create a custom class and implement the SearchQueryType
and OpenSearchQuery
interfaces.
If you were to implement the Query String query
it would look like the following:
and then just call it.
Aggregations
You can achieve the same for aggregations but instead of SearchQueryType
you need to implement the
AggregationType
inteface.
Contact Us
License
This project is licensed under the MIT License - see the LICENSE file for details.