v4.0.3 - (Unified with v3.9.3 & v3.8.3)
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://elasticsearch.pdphilip.com/es-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://elasticsearch.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.
Available aggregation functions: count
, avg
, min
, max
, sum
, matrix
.
Product::where('is_active',true)->agg(['count','avg','min','max','sum'],'sales');
https://elasticsearch.pdphilip.com/aggregation#grouped-aggregations
toDsl()
(or toSql()
)
Returns the parsed DSL query from the query builder
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://elasticsearch.pdphilip.com/es-specific#to-dsl
Tests for new features: https://github.com/pdphilip/laravel-elasticsearch-tests/blob/main/tests/EloquentTests/Update24-01Test.php
Bug fixes
- unset _meta on save. by @use-the-fork in #30
- Now throws an explicit error when trying to use
BelongsToMany()
which is not supported (but can be worked around easily)
Upgrades
- Fixed error tracking index for writing ES errors to a dedicated index
// database.php
'elasticsearch' => [
'driver' => 'elasticsearch',
//......
//......
//......
'error_log_index' => env('ES_ERROR_INDEX', false),
],
- White space code clean-up
New Contributors
- @use-the-fork made their first contribution in #30
Full Changelog: v4.0.2...v4.0.3