CustomScoreQuery in ElasticSearch

In Lucene i can using CustomScoreQuery to customize the score of Lucene search. So how to do similar thing in Elasticsearch.
My case :

  • Get field value from document
  • Do some computation
  • Elasticsearch score + my computation = new score

Hi ,CaoManhDat:

If you want to customize the score , may be you can use script score:

It can modify Elasticsearch score and add your computation like this:

"script_score" : {
    "script" : "_score * doc['my_numeric_field'].value"

you can also decide the script lang and use params:

"script_score": {
    "lang": "lang",
    "params": {
        "param1": value1,
        "param2": value2
    "script": "_score * doc['my_numeric_field'].value / pow(param1, param2)"

wish that may help you.

Best regard ,

Thanks you, but it no sufficient in my case. Because I need to transform field value in string -> rank in integer (dynamically).