Skip to content

Instantly share code, notes, and snippets.

@mikebaldry
Created November 21, 2013 15:42
Show Gist options
  • Save mikebaldry/7583901 to your computer and use it in GitHub Desktop.
Save mikebaldry/7583901 to your computer and use it in GitHub Desktop.
"sort": {
"_script": {
"script": "long lowestPublishedAt; for (int i = 0; i < _source.sources.size(); i++) { Boolean foundInList = false; for (int x = 0; x < external_ids.size(); x++) { if (external_ids[x] == _source.sources[i].external_id) { foundInList = true; break; } } if (foundInList) { if (i == 0 || _source.sources[i].published_at < lowestPublishedAt) { lowestPublishedAt = _source.sources[i].published_at; } } } return lowestPublishedAt;",
"type": "number",
"params": {
"external_ids": [
"a99240f3",
"a217f93"
]
},
"order": "asc"
}
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment