Search
Eclipse plugins are already integrated with the global search and Typesense.
Set up Scout and Typesense
In the default Eclipse app, Typesense is already configured as the Laravel Scout driver.
However, in case you need to add Typesense to an existing project, first add the service specification in your Lando file:
services:
typesense:
type: typesense:28.0
portforward: 8108
apiKey: abcRebuild the container with lando rebuild -y.
Secondly, follow the Scout installation instructions here, but do not change your model — this is done later below.
Then, set the same API key in your .env file and use typesense as host.
SCOUT_DRIVER=typesense
SCOUT_QUEUE=true
TYPESENSE_API_KEY=abc
TYPESENSE_HOST=typesenseThe Typesense service will now be running and ready to use by your app.
Preparing the model for search
- Add the
Eclipse\Common\Foundation\Models\IsSearchabletrait to your model class (e.g.Product). - Implement the
getTypesenseSettings()method in your model. For the key-value format, follow the Laravel Scout docs.
See our Product specification here in the catalogue plugin for a working example.
Notes: - Add the model settings to the Scout config.
In your service providerregistermethod, inject your model's settings into thescout.typesense.model-settingsconfig array, e.g.:phppublic function register() { parent::register(); $settings = Config::get('scout.typesense.model-settings', []); $settings += [ Product::class => Product::getTypesenseSettings(), // More models here... ]; Config::set('scout.typesense.model-settings', $settings); }
Enabling search in Filament controllers
- Add the
Eclipse\Common\Foundation\Pages\HasScoutSearchtrait to your FilamentListcontroller (e.g.ListProducts). - Add the
->searchable()method call to your table definition in your FilamentResourceclass (e.g.ProductResource).phppublic static function table(Table $table): Table { return $table ->columns([ TextColumn::make('id'), TextColumn::make('name') ->toggleable(false), ]) ->searchable(); } - Implement the
getGloballySearchableAttributes()method in theResourceclass to enable global search for the model, e.g.:phppublic static function getGloballySearchableAttributes(): array { return [ 'code', 'barcode', 'manufacturers_code', 'suppliers_code', 'name', 'short_description', 'description', ]; }
Indexing
Indexing happens on the fly when a model is saved, thanks to the IsSearchable trait.
However, when initially setting things up for an existing model with records in the database, you need to run the batch import. For our Product model, you could do that in the console like so:
php artisan scout:import "Eclipse\Catalogue\Product"Read more about indexing in the Laravel docs here.
Debugging
To better understand and help you debug any problems you may encounter when implementing search with Typesense, you can use the Typesense Dashboard. To access it, click the Typesense Dashboard link in the Tools nav menu. When asked for credentials, use the following settings:
- API Key: same as in your
.envfile (default:abc) - Protocol:
http - Host:
localhost - Port:
8108 - Path: (leave blank)
If you get CORS errors or other access problems, make sure to disable any browser protection, like Brave Shields, for the dashboard URL.