如何刷新Laravel Scout中的索引

时间:2018-05-05 08:12:49

标签: php laravel laravel-scout

我正在使用Laravel显示数据库(SQL Server)中的项目列表,这些项目将由另一个软件更新。因此,使用Laravel我只显示项目,没有插入,更新或删除功能。

我正在使用Laravel Scout和TNTSearch(https://github.com/teamtnt/laravel-scout-tntsearch-driver)搜索项目列表。问题是,每次数据库表发生变化时,如何刷新索引?

1 个答案:

答案 0 :(得分:0)

检查您拥有的索引,例如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

删除想要的索引

curl -XDELETE 'localhost:9200/statuses'

重新导入数据

php artisan scout:import "App\Status"

另一个删除快捷方式是

php artisan scout:flush "App\Status"