I have an AWS Elasticsearch instance provisioned and seeded with a bunch of band names. If I query it via cURL on the command line I get a nice set of weighted results including scores:
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"}},
However, when I use the elasticsearch/elasticsearch PHP package in my composer.json file:
"require": {
"elasticsearch/elasticsearch": "^2.2"
That completely ignores the _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"
]
]
I can't for the life of me figure out how to get the _scores to be reflected.
I'm trying to do this in a Laravel 5.3 application using laravel/scout, so the query is straight forward:
App\Band::search('Burn')->get();
but the problem lies in the elasticsearch package as I'll dump the results in there and see the 0.0 scores.
Kevin