Updated for more recent ElasticSearch Versions

custom_score has been deprecated and been replaced by function_score with a script_score now.

In order for this to work, scripting must be enabled in elasticsearch.yml:
script.disable_dynamic: false
See also: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-scripting.html