Skip to content

Instantly share code, notes, and snippets.

@pfeiffer
Created August 3, 2011 13:09
Show Gist options
  • Save pfeiffer/1122596 to your computer and use it in GitHub Desktop.
Save pfeiffer/1122596 to your computer and use it in GitHub Desktop.
Example query
{
"custom_score": {
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"and": [
{
"term": {
"hidden": false
}
}, {
"range": {
"current_sign_in_at": {
"gt": "2011-05-05"
}
}
},
null, {
"term": {
"sex": "female"
}
}, {
"term": {
"has_image": true
}
}, {
"bool": {
"must_not": [
{
"ids": {
"values": [26983, 313454],
"type": "user"
}
}]
}
}]
}
}
},
"script": "_score - Math.abs(doc['age'].value - age)/4.0 + (doc['partner_status'].value == 'single' ? 10 : 0) + (doc['has_image'].value == 'true' ? 40 : 0) + (doc['online'].value == 'true' ? 5 : 0) + (doc['boost'].value == 'true' ? 7 : 0) + (doc['current_sign_in_at'].value > stale_date ? 5 : 0) - (doc['location'].empty ? 20 : (doc['location'].distanceInKm(55.6808, 12.60591) * 0.14)) + (info['build'].indexOf(doc['info.build'].value) != -1 ? 10 : 0) + (info['children'].indexOf(doc['info.children'].value) != -1 ? 10 : 0)",
"params": {
"age": 24,
"weight": 73,
"height": 179,
"stale_date": 1311717600000,
"looking_for_age_from": null,
"looking_for_age_to": null,
"info": {
"build": [0, 1, 2],
"children": [0, 1, 2]
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment