I have an ElasticSearch query with a custom script score written in Painless language. For now the ES request looks like this, with the natural ES _score being totally replaced by a custom scoring from my script:
{
"_source": {
"excludes": [
"field_to_exclude",
]
},
"from": 0,
"size": 100,
"query": {
"script_score": {
"query": {
"bool": {
"must": {
"match_all": {}
},
"filter": [
{
"term": {
"field_to_filter": 4
}
}
]
}
},
"script": {
"lang": "painless",
"source": "COMPLEX_PAINLESS_SCRIPT"
}
}
},
"sort": [
{
"price": {
"order": "asc"
}
},
"_score"
]
}
Depending on some parameter from the frontend, I want to be able to still calculate the ES natural scoring separately, and keep this custom scoring to be calculated in another field, and even if possible being used as a secondary sorting criteria.
Is this possible?