Files
3dealer/config/lunar/search.php
T

81 lines
3.6 KiB
PHP

<?php
return [
/*
|--------------------------------------------------------------------------
| Models for indexing
|--------------------------------------------------------------------------
|
| The model listed here will be used to create/populate the indexes.
| You can provide your own model here to run them all on the same
| search engine.
|
*/
'models' => [
/*
* These models are required by the system, do not change them.
*/
Lunar\Models\Brand::class,
Lunar\Models\Collection::class,
Lunar\Models\Customer::class,
Lunar\Models\Order::class,
// Modules\Core\Catalog\Models\Product, not Lunar\Models\Product —
// both share the same underlying Meilisearch index name, so
// listing the base class here too would make every reindex
// (this default list is always merged in, even when a specific
// model is passed on the CLI — see Lunar\Console\Commands\
// ScoutIndexerCommand::handle()) run the base class's indexing a
// second time right after the subclass's, silently overwriting
// every document with one missing custom_fields/order_count
// (the whole reason Modules\Core\Catalog\Models\Product exists —
// see its own docblock). Caught in practice.
Modules\Core\Catalog\Models\Product::class,
Lunar\Models\ProductOption::class,
/*
* Below you can add your own models for indexing...
*/
// App\Models\Example::class,
],
/*
|--------------------------------------------------------------------------
| Search engine mapping
|--------------------------------------------------------------------------
|
| You can define what search driver each searchable model should use.
| If the model isn't defined here, it will use the SCOUT_DRIVER env variable.
|
*/
'engine_map' => [
// Lunar\Models\Product::class => 'algolia',
// Lunar\Models\Order::class => 'meilisearch',
// Lunar\Models\Collection::class => 'meilisearch',
],
'indexers' => [
Lunar\Models\Brand::class => Lunar\Search\BrandIndexer::class,
Lunar\Models\Collection::class => Modules\Core\Catalog\Services\CollectionIndexer::class,
Lunar\Models\Customer::class => Lunar\Search\CustomerIndexer::class,
Lunar\Models\Order::class => Lunar\Search\OrderIndexer::class,
// Lunar\Models\Product::class, NOT Modules\Core\Catalog\Models\
// Product::class — Lunar\Base\Traits\Searchable::indexer() (and
// getFilterableAttributes()/getSortableAttributes(), same trait)
// reads `$config[self::class]`, and `self::class` inside a TRAIT
// METHOD is a compile-time literal bound to whichever class first
// `use`s the trait — Lunar\Models\Product, since the subclass
// never re-declares indexer() itself — regardless of which
// instance actually calls the method at runtime. Keying this by
// the subclass here made the lookup miss entirely, silently
// falling back to Lunar\Search\ScoutIndexer's own near-empty
// filterable/sortable field list — confirmed live: it wiped every
// real filterable/sortable attribute the index had (including
// ones that already worked, like collection_ids), not just the
// new order_count one. Caught in practice, reverted.
Lunar\Models\Product::class => Modules\Core\Catalog\Services\ProductIndexer::class,
Lunar\Models\ProductOption::class => Lunar\Search\ProductOptionIndexer::class,
],
];