Skip to content

Instantly share code, notes, and snippets.

@xyu
Created April 11, 2016 01:23
Show Gist options
  • Save xyu/305b55b385f9eafabd0fd09b81f3f0fe to your computer and use it in GitHub Desktop.
Save xyu/305b55b385f9eafabd0fd09b81f3f0fe to your computer and use it in GitHub Desktop.
Example of Elasticsearch function scoring with gaussian decay
{
"query": {
"function_score": {
"query": {
"multi_match": {
"query": "...",
"fields": [
"title", "content", "author",
"tag.name", "category.name"
],
"cross_fields": true,
"operator": "and"
}
},
"filter": { ... },
"functions": [
{
"gauss": {
"origin": "now/d",
"scale": "7d",
"decay": 0.75
}
}
],
"score_mode": "multiply",
"boost_mode": "multiply"
}
}
}
@xyu
Copy link
Author

xyu commented Apr 18, 2016

See the following post on how to properly tune the decay parameters of the function score query:

https://xyu.io/2016/04/11/visualizing-elasticsearch-function-scores/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment