我正在使用带有 Elasticsearch 的传输器来索引和搜索记录,目前,它是使用以下命令完成的:
curl -XPOST "http://localhost:9200/_search?pretty=true" -d' { "query": { "multi_match" : { "query": "George bush", "fields": [ "first_name", "last_name", "full_name" ], "operator": "and", "fuzziness" : "AUTO" } } } ' -H 'Content-Type: application/json'
我已指定在和中搜索查询值first_name
,但它为每条记录提供了单个“_score”值,如下所示:last_name
full_name
{
"took" : 113,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 26,
"relation" : "eq"
},
"max_score" : 15.525349,
"hits" : [
{
"_index" : "db",
"_type" : "db",
"_id" : "60348c98d22c47e62bccfebb",
"_score" : 15.525349,
"_source" : {
"created_date_time" : "2021/02/17 01:44:50",
"designation" : "college basketball player (1950–1950) Toledo",
"education" : "['University of Toledo']",
"first_name" : "George",
"full_name" : "George Bush",
"gender" : "male",
"s_id" : "s_Q100766406",
"last_name" : null,
"mother" : null,
"native_name" : null,
"occupation" : "['Q3665646']",
}
},
我希望根据指定的字段“first_name_score”、“last_name_score”、“full_name_score”获得 3 个不同的分数,如下所示:
{
"took" : 113,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 26,
"relation" : "eq"
},
"max_score" : 15.525349,
"hits" : [
{
"_index" : "db",
"_type" : "db",
"_id" : "60348c98d22c47e62bccfebb",
"first_name_score" : 15.525349,
"last_name_score" : 12.292016,
"full_name_score" : 18.858672,
"_source" : {
"created_date_time" : "2021/02/17 01:44:50",
"designation" : "college basketball player (1950–1950) Toledo",
"education" : "['University of Toledo']",
"first_name" : "George",
"full_name" : "George Bush",
"gender" : "male",
"s_id" : "s_Q100766406",
"last_name" : null,
"mother" : null,
"native_name" : null,
"occupation" : "['Q3665646']",
}
},
怎么做?
是否有可能做到这一点?我是弹性搜索的初学者,所以如果有人能指出我正确的资源,那就太好了。