Skip to content

Instantly share code, notes, and snippets.

@devrimbaris
Last active January 23, 2018 06:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devrimbaris/4544310f50ca2df406d6aeeb4f57176c to your computer and use it in GitHub Desktop.
Save devrimbaris/4544310f50ca2df406d6aeeb4f57176c to your computer and use it in GitHub Desktop.
[elasticsearch] scripted field query
{
"sort" : [
{"processing_end_time" : {"order" :"asc"}}
],
"query": {
"bool" : {
"must" :{
"range":{
"processing_end_time": {
"gte": "now-1d/d"
}
}
},
"must" : {
"script" : {
"script" : {
"inline": "doc['processing_end_time'].value - doc['ingestion_time'].value > 6000",
"lang": "painless"
}
}
}
}
},
"script_fields": {
"scores": {
"script": {
"inline": "(doc['processing_end_time'].value - doc['ingestion_time'].value)/1000",
"lang": "painless"
}
}
},
"_source" : ["vin", "gpt", "ingestion_time","processing_end_time"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment