ankane/searchkick — pull request #300 by monkbroc (2014-10-09 20:53:31+00:00)
Title: Modify the query scoring with custom functions

First of all, thanks Andrew for the cool gem!

I wanted to customize the score by factoring in the distance from a point. The best way to do this seems to be with [function_score](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html).

There currently isn't a way to pass in a custom function_score argument. Other users apparently want to do this too as in #241.

This PR adds a :function_score option to the search method. function_score should be a hash that contains an array of functions and an optional score_mode (defaults to multiply).

I use it like this:

```
Model.search query_text, :function_score =>
{
:functions => [
{
:gauss => {
# The location field is a geo_point in Model
:location => {
# Longitude, Latitude to conform to GeoJSON
:origin => [location[:longitude], location[:latitude]],
:scale => "50mi",
:decay => 0.9
}
}
}
]
}
```