v4.3.0
This release marks a version bump within the 4.x branch due to one breaking change in rawSearch(). This branch is committed to Laravel 10 and 11 compatibility.
Breaking Change
rawSearch($bodyParams, $returnRaw = false) has now been split into rawSearch($bodyParams) and rawDsl($bodyParams) where:
rawSearch($bodyParams)returns an ElasticCollection of resultsrawDsl($bodyParams)returns the result body as is from Elasticsearch. Equivalent to$returnRaw = truepreviously.
New features
[1] Schema field mapping call: getFieldMapping(string|array $field = '*', $raw = false)
Schema method that can be called from your model:
Product::getFieldMapping('color'); //Returns a key/value array of field/types for color
Product::getFieldMapping('color',true); //Returns the mapping for color field as is from Elasticsearch
Product::getFieldMapping(['color','name']); //Returns maapings for color and name
Product::getFieldMapping(); //returns all field mappings, same as getFieldMapping('*')or via Schema: Schema::getFieldMapping($index, $field, $raw)
Schema::getFieldMapping('products','color',true); [2] Order By Random: orderByRandom(string $column, int $seed = 1)
Uses ES's random_score to randomise ordering
Product::where('color', 'silver')->orderByRandom('created_at', rand(1, 1000))->limit(5)->get();The value of $seed will return the same results if unchanged. This is required for consistencey, ex: pagination
Bug fix
whereExact() keyword field validator has been fixed
PRs
- Refract/code coverage - Coverage up to 79% by @use-the-fork in #40
- fix(DSL): improve keyword mapping handling for nested fields by @use-the-fork in #43
- feat(elasticsearch): enhance raw search functionality by @use-the-fork in #44
Full Changelog: v4.2.0...v4.3.0