Skip to content

Instantly share code, notes, and snippets.

@yehosef
Last active November 22, 2016 21:03
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yehosef/f96dc491bcd5ee9bf7d3 to your computer and use it in GitHub Desktop.
Save yehosef/f96dc491bcd5ee9bf7d3 to your computer and use it in GitHub Desktop.
elasticsearch avg problem
{
"size": 0,
"query": {
"filtered": {
"query": {
"query_string": {
"query": "*",
"analyze_wildcard": true
}
},
"filter": {
"bool": {
"must": [
{
"range": {
"@timestamp": {
"gte": 1402141719395,
"lte": 1433677719395
}
}
}
],
"must_not": []
}
}
}
},
"aggs": {
"2": {
"date_histogram": {
"field": "@timestamp",
"interval": "1w",
"pre_zone": "+03:00",
"pre_zone_adjust_large_interval": true,
"min_doc_count": 1,
"extended_bounds": {
"min": 1402141719394,
"max": 1433677719395
}
},
"aggs": {
"1": {
"avg": {
"script": "doc['properties.Page: Number Pageview'].value * 2",
"lang": "expression"
}
},
"4": {
"avg": {
"field": "properties.Page: Number Pageview"
}
}
}
}
}
}
//PUT _template/logging_default
{
"template": "logstash-*",
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
},
"mappings": {
"_default_": {
"dynamic_templates": [
{
"notanalyzed": {
"match": "*",
"match_mapping_type": "string",
"mapping": {
"index": "not_analyzed",
"type": "string",
"stored":false,
"doc_values": true
}
}
}
],
"_all": {"enabled": false},
"_source" : {"enabled" : false}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment