I have millions of records. I want to get the average of a specific field, but can only return less that 10,000 rows.
Is the average returned is the real average of the millions of rows, or the average of the returned rows?
This is the query I run:
{
"query": {
"bool": {
"must": [
{
"bool": {
"should": [
{
"term": {
"ccpair":"EUR / USD"
}
},
{
"term": {
"ccpair":"EUR/USD"
}
},
{
"term": {
"ccpair":"EUR/USD-"
}
}]
}
},
{
"bool": {
"must": [
{
"term": {
"tnetServerName": "saxo-p.tradair.com"
}
}]
}
}
]
}
},
"aggs": {
"platformNames": {
"terms": {
"field": "platformName",
"size": 5
},
"aggs": {
"per_hour": {
"date_histogram": {
"field": "timestamp",
"interval": "hour"
},
"aggs": {
"by_top_hit": {
"top_hits": {
"size": <does the size really matter?>
}
},
"aggs": {
"nested": {
"path": "tiers"
},
"aggs": {
"avg_spread2": {
"avg": {
"field": "tiers.spread"
}
}
}
}
}
}
}
}
}
}