【问题标题】:Laravel Scout with Elastic search not working带有弹性搜索的 Laravel Scout 不起作用
【发布时间】: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


【解决方案1】:

如果您使用的是弹性搜索,请检查错误日志 - 我有:

sudo su 

tail -f /var/log/elasticsearch/elasticsearch.log


high disk watermark [90%] exceeded on [minbqqKpRV-umA0DPxkuww][mihai-MS-7A72][/var/lib/elasticsearch/nodes/0] free: 28.9gb[6.3%], shards will be relocated away from this node; currently relocating away shards totalling [0] bytes; the node is expected to continue to exceed the high disk watermark when these relocations are complete

如果是这种情况,请禁用磁盘检查,至少用于测试

curl -XPUT -H "Content-Type: application/json" \
   http://localhost:9200/_all/_settings \
     -d '{"index.blocks.read_only_allow_delete": false}'

或者将这些更改永久保存在 elasticsearch.yml 中并重新启动服务。

【讨论】:

    【解决方案2】:

    我遇到了同样的问题。 删除 Elasticsearch 中的索引并运行:

    php artisan scout:import App\\story
    

    让 scout 创建它。

    【讨论】:

      【解决方案3】:

      设置 QUEUE=sync 或者您可以在 config/scout.php 上关闭队列。

      遇到同样的问题:https://github.com/ErickTamayo/laravel-scout-elastic/issues/43

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-08-20
        • 2021-08-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多