首页 > 解决方案 > 使用 scout 包在 laravel 弹性搜索中找不到索引异常

问题描述

我已经安装了laravel 的 tamayo/laravel-scout-elastic包,并且我确实导入了我的产品表记录,但是每当我搜索任何内容时,我都会收到“未找到索引异常”。下面是我对scout.php文件的配置

`'elasticsearch' => [

    'index' => env('ELASTICSEARCH_INDEX', 'marketplace'),

    'hosts' => [
        env('ELASTICSEARCH_HOST', 'http://localhost:9200'),
    ],
],`

当我这样做时curl 'localhost:9200/marketplace/_mapping?pretty',我得到了以下回复。

`{

  "error" : {

"root_cause" : [ {

  "type" : "index_not_found_exception",

  "reason" : "no such index",

  "resource.type" : "index_or_alias",

  "resource.id" : "marketplace",

  "index" : "marketplace"

} ],

"type" : "index_not_found_exception",

"reason" : "no such index",

"resource.type" : "index_or_alias",

"resource.id" : "marketplace",

"index" : "marketplace"

  },

  "status" : 404

}`

我错过了那里的东西吗?任何帮助将非常感激。

标签: phplaravelelasticsearchlaravel-scout

解决方案


您是否通过 URL http://localhost:9200/marketplace 使用 PUT 方法添加了索引?(使用 cli。curl --location --request PUT 'http://localhost:9200/some_index')


推荐阅读