diff --git a/src/Http/Controllers/ConfigController.php b/src/Http/Controllers/ConfigController.php index 689a25dfb..eea20c781 100644 --- a/src/Http/Controllers/ConfigController.php +++ b/src/Http/Controllers/ConfigController.php @@ -249,7 +249,7 @@ public function getSearchkitSorting(): array "rapidez::frontend.sorting.{$attribute['code']}.{$direction}", trans_fallback("rapidez::frontend.{$attribute['code']}", ucfirst($attribute['code'])) . ' ' . trans_fallback("rapidez::frontend.{$direction}", $direction), ), - 'field' => $attribute['code'] . ($attribute['input'] == 'text' ? '.keyword' : ''), + 'field' => $attribute['code'] . ($attribute['code'] !== 'created_at' && $attribute['input'] == 'text' ? '.keyword' : ''), 'order' => $direction, 'value' => "{$index}_{$attribute['code']}_{$direction}", 'key' => "_{$attribute['code']}_{$direction}", diff --git a/src/Models/Traits/Product/Searchable.php b/src/Models/Traits/Product/Searchable.php index 37ecd09f4..cd56ef69e 100644 --- a/src/Models/Traits/Product/Searchable.php +++ b/src/Models/Traits/Product/Searchable.php @@ -168,6 +168,10 @@ protected static function indexMapping(): array return false; } + if (in_array($attribute['code'], ['created_at'])) { + return true; + } + if (in_array($attribute['type'], ['varchar', 'text', 'gallery', 'static'])) { // Types best left up to ES to interpret the type. return false; @@ -196,7 +200,11 @@ protected static function indexMapping(): array }) ) ->pluck('type', 'code') - ->map(function ($type) { + ->map(function ($type, $code) { + if (in_array($code, ['created_at'])) { + $type = 'datetime'; + } + return array_filter([ 'type' => match ($type) { 'int' => 'integer',