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),
],