Skip to content

Instantly share code, notes, and snippets.

@bmichalski
Created September 28, 2015 18:15
Show Gist options
  • Save bmichalski/587c0de72188977ce053 to your computer and use it in GitHub Desktop.
Save bmichalski/587c0de72188977ce053 to your computer and use it in GitHub Desktop.
ElasticSearch test expression script with aggregation
{
"testVal": 25,
"testQuantity": 5
}
{
"mappings" : {
"test" : {
"properties" : {
"testVal" : { "type" : "long", "index" : "not_analyzed" },
"testQuantity" : { "type" : "long", "index" : "not_analyzed" }
}
}
}
}
{
"aggs": {
"testAgg": {
"sum": {
"lang": "expression",
"script": "doc['testVal'].value * doc['testQuantity'].value"
}
}
}
}
mapping:
http://localhost:9200/test/test/ PUT
create_entries:
http://localhost:9200/test/test/ POST
query:
http://localhost:9200/test/test/_search?search_type=count POST
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment