laravel - Laravel用ElasticSearch进行侦察,如何重置索引?

标签 laravel elasticsearch laravel-5.3

我正在开发Laravel项目,并且在模型Offer上将https://laravel.com/docs/5.3/scout与ElasticSearch结合使用。

使用php artisan scout:import "App\Models\Offer"命令,我可以从数据库中使用offers为ElasticSearch生成索引,这没关系。之后,我可以在该索引中搜索offers

但是现在,我从数据库中删除了一些offers,并且我不知道如何重置或重新生成删除旧ID的索引?

例如,我在数据库中删除了Offer with id = 15,但是当我执行搜索时,此报价(id = 15)始终被索引,并且由于该报价不存在而出现错误。

我试图重新运行scout:import命令,但没有效果。我唯一喜欢的解决方案是用https://laravel.com/docs/master/scout#configuring-model-indexes重命名索引,但是我不能每次都这样做。

有任何想法吗 ?

最佳答案

您可以使用php artisan scout:flush "App\Models\Offer"
您还可以从storage文件夹中删除索引的物理文件

关于laravel - Laravel用ElasticSearch进行侦察,如何重置索引?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40630880/

相关文章:

php - 在这种情况下是否可以有一个可为空的外键?

mysql 加入 ON 和 AND 到 laravel Eloquent

elasticsearch - Filebeat 多行过滤器不起作用?

elasticsearch - JanusGraph - 数据如何存储在 ElasticSearch 和 Cassandra 中?

php - 将 Laravel 默认用户数据库连接更改为另一个数据库连接

notifications - Laravel 5.3 检查通知是否被读取

php - QueryException SQLSTATE[HY000] [2002] 无法连接到 MySQL 服务器

php - 如何增加laravel的最大执行时间?

c# - 带有附加 TermAggregation 的 TermAggregation 在 AggregationDictionary 中不起作用

php - Blade if() 条件错误