Last active
September 28, 2015 18:44
-
-
Save bmichalski/cda72240d44ca55ad50c to your computer and use it in GitHub Desktop.
ElasticSearch test expression script with aggregation and sub aggregations
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
{ | |
"color": "black", | |
"testVal": 25, | |
"testQuantity": 5 | |
} |
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
{ | |
"mappings" : { | |
"test" : { | |
"properties" : { | |
"color": { "type" : "string", "index" : "not_analyzed" }, | |
"testVal" : { "type" : "long", "index" : "not_analyzed" }, | |
"testQuantity" : { "type" : "long", "index" : "not_analyzed" } | |
} | |
} | |
} | |
} |
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
{ | |
"aggs": { | |
"testColor": { | |
"terms": { | |
"field": "color" | |
}, | |
"aggs": { | |
"testAgg": { | |
"sum": { | |
"lang": "expression", | |
"script": "doc['testVal'].value * doc['testQuantity'].value" | |
} | |
} | |
} | |
} | |
} | |
} |
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
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