My requirement is to update _score based on an attribute. Below is my request:
{
"_source": {
"excludes": [],
"includes": [
"somefield1",
"fqn_completion"
"somefield2"
]
},
"suggest": {
"suggest_fqn": {
"completion": {
"field": "fqn_completion.US",
"size": 10,
"skip_duplicates": true
},
"prefix": "unit"
},
"suggest_fqn_alt1": {
"completion": {
"field": "fqn_alt1_completion.US",
"size": 10,
"skip_duplicates": true
},
"prefix": "Kansas"
},
"suggest_fqn_alt2": {
"completion": {
"field": "fqn_alt2_completion.US",
"size": 10,
"skip_duplicates": true
},
"prefix": "Kansas"
}
},
"track_total_hits": true
}
And below is response of the above request:
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
},
"suggest": {
"suggest_fqn": [
{
"text": "unit",
"offset": 0,
"length": 4,
"options": [
{
"text": "UNITY,WI,United States",
"_index": "index name",
"_type": "_doc",
"_id": "asdasdasdasads",
"_score": 1.0,
"_source": {
"somefield1": "something",
"somefield2": 12345,
"fqn_completion": {
"US": "UNITY,WI,United States"
},
"fqn_alt1_completion": {
"US": null
},
"fqn_alt2_completion": {
"US": null
}
}
}
]
}
],
"suggest_fqn_alt1": [
{
"text": "Kansas",
"offset": 0,
"length": 6,
"options": [
{
"text": "UNITY TWP,PA,United States",
"_index": "index name",
"_type": "_doc",
"_id": "asdasdasdasads",
"_score": 1.0,
"_source": {
"somefield1": "something",
"somefield2": 12312,
"fqn_completion": {
"US": "UNITY TWP,PA,United States"
},
"fqn_alt1_completion": {
"US": null
},
"fqn_alt2_completion": {
"US": null
}
}
}
]
}
],
"suggest_fqn_alt2": [
{
"text": "Kansas",
"offset": 0,
"length": 6,
"options": []
}
]
}
}
I want to update _score with somefield2 value. I thought of use function_score but how to use it in above request that I couldn't figure it out. Anyone has any idea how can I achieve it?