Forked from darklow/elasticsearch.custom.sort.py
Last active
November 21, 2016 18:20
-
-
Save fosstrack/b16ccb726fe88c8347f9 to your computer and use it in GitHub Desktop.
Updated script to avoid org.elasticsearch.index.mapper.Uid.idFromUid which no longer works. Cast the doc['id'].value as needed to enable array look up. This is based on a comment by the original author elsewhere.
This file contains 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
q = { | |
"query": { | |
"function_score": { | |
"boost_mode": "replace", | |
"query": { | |
"ids": { | |
"values": [ | |
50, | |
80, | |
44, | |
12 | |
] | |
} | |
}, | |
"script_score": { | |
"params": { | |
"ids": [ | |
50, | |
80, | |
44, | |
12 | |
] | |
}, | |
"script": "return -ids.indexOf((int)doc['id'].value);" | |
} | |
} | |
}, | |
"size": 20, | |
"from": 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment