小编Pra*_*gam的帖子

带有弹性搜索的 Laravel Scout 不起作用

我试过

  • 将弹性搜索与 Laravel scout 与包结合使用

    "laravel/scout": "^1.0",
    "tamayo/laravel-scout-elastic": "^1.0"
    
    Run Code Online (Sandbox Code Playgroud)
  • 在 localhost:9200 中运行 Elasticsearch 服务器并创建索引并提供必要的配置,

  • 向模型添加了可搜索的特征,

  • 并将数据导入到索引中

    php artisan scout:import "App\story"
    Imported [App\story] models up to ID: 4
    All [App\story] records have been imported.
    
    Run Code Online (Sandbox Code Playgroud)

但是当我进行搜索时,它返回一个空数组

 story::search("the")->get()
 => Illuminate\Database\Eloquent\Collection {#754
      all: [],
 }
Run Code Online (Sandbox Code Playgroud)

当我卷曲时,它也显示为,

// 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": [
            
          ]
        }
      }
Run Code Online (Sandbox Code Playgroud)

当我在 ES 中添加没有索引的记录时,模型会抛出类似index not found. 但是在添加数据和所有之后,它似乎是空的。我错过了什么吗?

与 algolia 完全相同。

elasticsearch laravel-5 laravel-scout

5
推荐指数
1
解决办法
3419
查看次数

标签 统计

elasticsearch ×1

laravel-5 ×1

laravel-scout ×1