繁体   English   中英

如何在 Laravel Scout 中刷新索引

[英]How to refresh indexes in Laravel Scout

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

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

我制作了一个 package,它将使用 Scouts scout:flushscout:import命令在您的应用程序中的任何位置每隔 model 刷新一次

https://github.com/tarreislam/laravel-scout-refresh

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM