Created
July 28, 2011 07:42
-
-
Save pfeiffer/1111165 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"custom_score": { | |
"query": { | |
"filtered": { | |
"query": { | |
"match_all": { } | |
}, | |
"filter": { | |
"and": [ | |
{ | |
"term": { | |
"hidden": false | |
} | |
}, | |
{ | |
"range": { | |
"current_sign_in_at": { | |
"gt": "2011-04-29" | |
} | |
} | |
}, | |
{ | |
"term": { | |
"sex": "female" | |
} | |
}, | |
{ | |
"term": { | |
"has_image": true | |
} | |
}, | |
{ | |
"bool": { | |
"must_not": [ | |
{ | |
"terms": { | |
"_id": [ | |
1, | |
4, | |
6, | |
10, | |
4999, | |
391034, | |
1839 | |
] | |
} | |
} | |
] | |
} | |
} | |
] | |
} | |
} | |
}, | |
"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.714619, 12.5287294) * 0.14))", | |
"params": { | |
"age": 24, | |
"weight": null, | |
"height": null, | |
"stale_date": 1311199200000 | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Third step can be to cache the tuple of certain filters for better perf, for example, created a tuple of
hidden
,sex
, andhas_image
into a single cached element, so theand
filter will be faster: