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
In Lucene i can using CustomScoreQuery to customize the score of Lucene search. So how to do similar thing in Elasticsearch.
My case :
Hi ,CaoManhDat:
If you want to customize the score , may be you can use script score:
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html#_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 ,
shinyke
Thanks you, but it no sufficient in my case. Because I need to transform field value in string -> rank in integer (dynamically).
© 2020. All Rights Reserved - Elasticsearch
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant logo are trademarks of the Apache Software Foundation in the United States and/or other countries.