I'm using Laravel to show a list of items from a database (SQL Server) that will be updated by another piece of software. So, with Laravel I only show items, without the insert, update or remove features.
I'm using Laravel Scout with TNTSearch ( https://github.com/teamtnt/laravel-scout-tntsearch-driver ) for searching in the list of items. The problem is, how can I refresh the index every time there is a change in the database table?
I have made a package that will refresh every model anywhere in your application using Scouts scout:flush
and scout:import
command
Check the indices you have,for example elasticsearch
curl 'localhost:9200/_cat/indices?v'
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
yellow open statuses GBNC5c4jQiqgNqBMEGJJJw 1 1 1 0 5.7kb 5.7kb
yellow open users Sndfs-KeQWeK6zv5p8BEpw 1 1 52 7 72.6kb 72.6kb
Delete the desired index
curl -XDELETE 'localhost:9200/statuses'
Reimport the data
php artisan scout:import "App\Status"
Another shorcut for delete is
php artisan scout:flush "App\Status"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.