Download the PHP package nwogu/laravel-searchman without Composer
On this page you can find all versions of the php package nwogu/laravel-searchman. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-searchman
laravel-searchman
MySql Driver for Laravel Scout
Requirements
- Requires Laravel Installed ^5.6
- Requires Laravel Scout ^7.0
Installation
Setup
Searchman Provides a Mysql Driver for Laravel Scout, for full text search
with indexing priorities and sql where expressions.
After installing Searchman, you can publish the configuration
using the vendor:publish Artisan command. This command will publish the searchman.php
configuration file to your config directory:
Add the trait to the model you would like to make searchable. This trait uses Laravel's Scout Searchable and adds extra methods required by the engine:
As with Scout, you can overide the method in your model to change
the default index table name.
Queuing
As at v1.0.1, Searchman has not been effectively tested with queues.
Migrations
Run the command to generate the index
for the specific model.
A migration file will be created in laravel's default base migrations folder.
run the migration with to publish the migration.
At the point, you can now start indexing your models.
Priority Handlers
Searchman is built around indexing priorities. By default, two priority handlers
are available for use
- Nwogu\SearchMan\PriorityHandlers\LocationPriorityHandler
- Nwogu\SearchMan\PriorityHandlers\LongTextPriorityHandler
You can specify which handler to use for your indexing by defining the method
on your indexable model. It should return an array
specifing the column name and the handler.
By default, the LocationPriorityHandler is used for all indexing. you can
overide this in the searchman config file.
Building your own handlers is easy. Implement the Priority handler Interface and you are good to go.
Searching
Laravel Scout only suports strict where clauses. but with Searchman, you can specify the operation of
your statements using .
For more on search, look up the Laravel Scout Documentation
Results
Calling get on your query would return an Eloquent collection of models sorted by the priority attribute.