【发布时间】:2017-05-18 23:43:44
【问题描述】:
我试过了
-
将弹性搜索与 Laravel scout 和包一起使用
"laravel/scout": "^1.0", "tamayo/laravel-scout-elastic": "^1.0" -
在 localhost:9200 中运行 Elasticsearch 服务器并创建索引并提供必要的配置,
-
为模型添加了可搜索的特征,
-
并将数据导入到索引中
php artisan scout:import "App\story" Imported [App\story] models up to ID: 4 All [App\story] records have been imported.
但是当我进行搜索时,它会返回一个空数组
story::search("the")->get()
=> Illuminate\Database\Eloquent\Collection {#754
all: [],
}
当我卷曲时,它也会显示,
// http://localhost:9200/author/_search?pretty=true&q=*:*
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": [
]
}
}
当我在 ES 中添加没有索引的记录时,模型会抛出类似 index not found 的错误。但是在添加数据和所有之后,它似乎是空的。我错过了什么吗?
同样适用于 algolia。
【问题讨论】:
-
看起来你的索引是空的,如果 curl 没有返回记录。
-
我的问题是数据没有通过 laravel 中的侦察接口添加到我的索引中。
-
我也遇到了同样的问题,不知道你有没有发现,但我没有。我最终没有使用 Scout
标签: elasticsearch laravel-5 laravel-scout