[英]How to refresh indexes in Laravel Scout
I'm using Laravel to show a list of items from a database (SQL Server) that will be updated by another piece of software.我正在使用 Laravel 来显示数据库 (SQL Server) 中的项目列表,这些项目将由另一个软件更新。 So, with Laravel I only show items, without the insert, update or remove features.因此,对于 Laravel,我只显示项目,没有插入、更新或删除功能。
I'm using Laravel Scout with TNTSearch ( https://github.com/teamtnt/laravel-scout-tntsearch-driver ) for searching in the list of items.我正在使用 Laravel Scout 和 TNTSearch ( https://github.com/teamtnt/laravel-scout-tntsearch-driver ) 在项目列表中搜索。 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我制作了一个 package,它将使用 Scouts scout:flush
和scout:import
命令在您的应用程序中的任何位置每隔 model 刷新一次
https://github.com/tarreislam/laravel-scout-refresh https://github.com/tarreislam/laravel-scout-refresh
Check the indices you have,for example elasticsearch检查您拥有的索引,例如 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"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.