Releases: pdphilip/laravel-opensearch
v2.0.4
What's Changed
- query operator as lowercase to escape case-sensitive troubles. by @sergoslav in #9
New Contributors
- @sergoslav made their first contribution in #9
Full Changelog: v2.0.3...v2.0.4
v2.0.3
This unified release includes updates for multiple Laravel versions:
Upgrades
sum()
,avg()
,min()
andmax()
can now process multiple fields in one call
Product::where('color','blue')->avg(['orders', 'price']);
//Previously required two separate calls:
Product::where('color','blue')->avg('orders');
Product::where('color','blue')->avg('price');
rawSearch(array $bodyParams, bool $returnRaw = false)
- a second bool parameter will return data as is (unsanitized) if set to
true
Product::rawSearch($body, true);
Bug fixes
- rawAggregation with multiple aggregations now returns all aggs
- Fixed issue when saving fields where the data didn't change threw an error
Full Changelog: v2.0.2...v2.0.3
v2.0.2 - (Unified with v1.0.2)
This unified release includes updates for multiple Laravel versions:
New Features
wherePhrasePrefix($field, $phraseWithPrefix)
Method for looking up a specific sequence of words where the last word starts with a particular prefix
Person::wherePhrasePrefix('description', 'loves es')->get();
// returns: loves espresso, loves essays, loves eskimos, etc
Docs: https://opensearch.pdphilip.com/os-specific#where-phrase-prefix
phrase($field)
Method for searching across multiple fields for a specific phrase (sequence of words in order)
Book::phrase('United States')->orPhrase('United Kingdom')->search();
// Search for books that contain either 'United States' or 'United Kingdom', phrases like 'United Emirates' will not be included.
Docs: https://opensearch.pdphilip.com/full-text-search#phrase-search-phrase
agg(array $functions,$field)
Optimization method that allows you to call multiple aggregation functions on a single field in one call. Issue #3
Available aggregation functions: count
, avg
, min
, max
, sum
, matrix
.
Product::where('is_active',true)->agg(['count','avg','min','max','sum'],'sales');
Docs: https://opensearch.pdphilip.com/aggregation#grouped-aggregations
toDsl()
(or toSql()
)
Returns the parsed DSL query from the query builder. Issue #2
Product::whereIn('color', ['red', 'green'])->orderByDesc('sales')->toDsl();
Returns
{
"index": "products",
"body": {
"query": {
"terms": {
"color.keyword": [
"red",
"green"
]
}
},
"_source": [
"*"
],
"sort": [
{
"sales": {
"order": "desc"
}
}
]
}
}
Docs: https://opensearch.pdphilip.com/os-specific#to-dsl
Bug fixes
- Fixed issue where meta data was being written to indexes in some cases
Upgrades
- Fixed error tracking index for writing OS errors to a dedicated index - Issue #4
// database.php
'opensearch' => [
'driver' => 'opensearch',
//......
//......
//......
'error_log_index' => env('OS_ERROR_INDEX', false),
],
- White space code clean-up
'opensearch' => [
'driver' => 'opensearch',
'hosts' => explode(',', env('OS_HOSTS', 'http://localhost:9200')),
'basic_auth' => [
'username' => env('OS_USERNAME', ''),
'password' => env('OS_PASSWORD', ''),
],
'sig_v4' => [
'provider' => env('OS_SIG_V4_PROVIDER'),
'region' => env('OS_SIG_V4_REGION'),
'service' => env('OS_SIG_V4_SERVICE'),
],
'ssl' => [
'cert' => env('OS_SSL_CERT', ''),
'cert_password' => env('OS_SSL_CERT_PASSWORD', ''),
'key' => env('OS_SSL_KEY', ''),
'key_password' => env('OS_SSL_KEY_PASSWORD', ''),
],
'index_prefix' => env('OS_INDEX_PREFIX', false),
'options' => [
'ssl_verification' => env('OS_OPT_VERIFY_SSL', true),
'retires' => env('OS_OPT_RETRIES'),
'sniff_on_start' => env('OS_OPT_SNIFF_ON_START'),
'port_in_host_header' => env('OS_OPT_PORT_HOST_HEADERS'),
],
'error_log_index' => env('OS_ERROR_INDEX', false),
],
'opensearch_cloud' => [
'driver' => 'opensearch',
'hosts' => explode(',', env('OS_CLOUD_HOSTS', 'http://localhost:9200')),
'basic_auth' => [
'username' => env('OS_CLOUD_USERNAME', ''),
'password' => env('OS_CLOUD_PASSWORD', ''),
],
'sig_v4' => [
'provider' => env('OS_CLOUD_SIG_V4_PROVIDER'),
'region' => env('OS_CLOUD_SIG_V4_REGION'),
'service' => env('OS_CLOUD_SIG_V4_SERVICE'),
],
'ssl' => [
'cert' => env('OS_CLOUD_SSL_CERT', ''),
'cert_password' => env('OS_CLOUD_SSL_CERT_PASSWORD', ''),
'key' => env('OS_CLOUD_SSL_KEY', ''),
'key_password' => env('OS_CLOUD_SSL_KEY_PASSWORD', ''),
],
'index_prefix' => env('OS_CLOUD_INDEX_PREFIX', false),
'options' => [
'ssl_verification' => env('OS_CLOUD_OPT_VERIFY_SSL', true),
'retires' => env('OS_CLOUD_OPT_RETRIES'),
'sniff_on_start' => env('OS_CLOUD_OPT_SNIFF_ON_START'),
'port_in_host_header' => env('OS_CLOUD_OPT_PORT_HOST_HEADERS'),
],
'error_log_index' => env('OS_CLOUD_ERROR_INDEX', false),
],
v2.0.1
New Features
New numeric type mappings for IndexBlueprint
double($field)
- A double-precision 64-bit IEEE 754 floating point number, restricted to finite values.byte($field)
- A signed 8-bit integer with a minimum value of -128 and a maximum value of 127.halfFloat($field)
- A half-precision 16-bit IEEE 754 floating point number, restricted to finite values.scaledFloat($field, $scalingFactor = 100)
- A floating point number that is backed by a long, scaled by a fixed double scaling factor.unsignedLong($field)
- An unsigned 64-bit integer with a minimum value of 0 and a maximum value of 264-1.
Example:
Schema::create('my_index', function (IndexBlueprint $index) {
$index->double('some_field_a');
$index->byte('some_field_b');
$index->halfFloat('some_field_c');
$index->scaledFloat('some_field_d', 100);
$index->unsignedLong('some_field_e');
});
Bug fixes
- Fixed Connection to process options
Full Changelog: v2.0.0...v2.0.1
v1.0.1
New Features
New numeric type mappings for IndexBlueprint
double($field)
- A double-precision 64-bit IEEE 754 floating point number, restricted to finite values.byte($field)
- A signed 8-bit integer with a minimum value of -128 and a maximum value of 127.halfFloat($field)
- A half-precision 16-bit IEEE 754 floating point number, restricted to finite values.scaledFloat($field, $scalingFactor = 100)
- A floating point number that is backed by a long, scaled by a fixed double scaling factor.unsignedLong($field)
- An unsigned 64-bit integer with a minimum value of 0 and a maximum value of 264-1.
Example:
Schema::create('my_index', function (IndexBlueprint $index) {
$index->double('some_field_a');
$index->byte('some_field_b');
$index->halfFloat('some_field_c');
$index->scaledFloat('some_field_d', 100);
$index->unsignedLong('some_field_e');
});
Bug fixes
- Fixed Connection to process options
Full Changelog: v1.0.0...v1.0.1
v2.0.0
Initial Release for Laravel 10 & 11
composer require pdphilip/elasticsearch:~2
Documentation: https://opensearch.pdphilip.com/
Note: This package has been built off the back of the original Elasticsearch version of this package
v1.0.0
Initial Release for Laravel 8 & 9
composer require pdphilip/elasticsearch:~1
Documentation: https://opensearch.pdphilip.com/
Note: This package has been built off the back of the original Elasticsearch version of this package