Plug-in Java or Python or Scala function to re-calculate document score?


#1

Hello ElasticSearch experts,

Is it possible to plug-in Java or Python or Scala customized function (any one of them is ok) into ElasticSearch cluster, so that for each returned documents, we can use the customized function to calculate a document score based on fields of documents? And return ordered document based on customized function score?

If so, any samples is appreciated.

thanks in advance,
Lin


(Nik Everett) #2

https://www.elastic.co/guide/en/elasticsearch/reference/1.6/query-dsl-function-score-query.html#function-script-score

See the script_score. You can use a native script if you are ok with deploying it into Elasticsearch's classpath. If its simple enough you can use "expression" which is the Lucene Expression language. Its plenty for lots of use cases and its fast and sandboxed.


#3

Thanks Nik,

Is there a guide how to write a sample native script and deploy into ElasticSearch's class path, and leverage it during query?

BTW, I have another question on customized scoring, and if you could comment, it will be great,

regards,
Lin


(system) #4