PHP Elasticsearch为所有分数返回0.0

时间:2016-09-13 04:27:25

标签: php laravel elasticsearch

我已经配置了一个AWS Elasticsearch实例,并使用一堆波段名称播种。如果我在命令行上通过cURL查询它,我得到一组很好的加权结果,包括分数:

curl -XGET 'search-mydomain-3gk2dsu32xfb5ar4kcfablqjla.us-west-2.es.amazonaws.com:80/index/bands/_search?q=Burn'

{"took":13,"timed_out":false,"_shards":
    {"total":5,"successful":5,"failed":0},"hits":
        {"total":17,"max_score":5.6469817,"hits":
            [{"_index":"index","_type":"bands","_id":"17554","_score":5.6469817,"_source":{"id":17554,"band":"Burn Witch Burn"}},
                  {"_index":"index","_type":"bands","_id":"30730","_score":4.617216,"_source":{"id":30730,"band":"Burn Halo"}},

但是,当我在composer.json文件中使用elasticsearch / elasticsearch PHP包时:

   "require": { 
       "elasticsearch/elasticsearch": "^2.2"

这完全忽略了_scores:

       "hits" => array:3 [
      0 => array:5 [
        "_index" => "index"
        "_type" => "bands"
        "_id" => "2890"
        "_score" => 0.0
        "_source" => array:2 [
          "id" => 2890
          "band" => "Jack Starr's Burning Starr"
        ]
      ]
      1 => array:5 [
        "_index" => "index"
        "_type" => "bands"
        "_id" => "8381"
        "_score" => 0.0
        "_source" => array:2 [
          "id" => 8381
          "band" => "D. Greenfield & J.J. Burnel"
        ]
      ]

我不能为我的生活弄清楚如何让_scores得到反映。

我正在尝试使用laravel / scout在Laravel 5.3应用程序中执行此操作,因此查询很简单:

App\Band::search('Burn')->get();

但问题出在elasticsearch包中,因为我会将结果转储到那里并看到0.0分。

凯文

0 个答案:

没有答案