Post aggregation with topN query not working ok if fields start with the type constant and fn:"/"

Hi All,

This is the simple query with topN I run

{

“queryType”:“topN”,

“dataSource”:“igwcdrv1”,

“granularity”:“all”,

“threshold”:5,

“dimension”: “COUNTRY”,

“metric”:“post1”,

“aggregations”:[{“display”:true,“name”:“agg1”,“type”:“count”}],

“postAggregations”:[

{

“name”:“post1”,

“type”:“arithmetic”,

“fn”:"/",

“fields”:[

{“type”:“constant”,“value”:3000},

{“type”:“fieldAccess”,“name”:“agg1”,“fieldName”:“agg1”}

]

}

],

“intervals”:[“2016-08-23T07:58:59.749Z/2017-02-23T08:58:59.749Z”]}

}

and I am getting the result show below in which agg1 is always taken as 1 .

[ {

“timestamp” : “2016-12-12T14:11:00.000Z”,

“result” : [ {

"COUNTRY" : "Angola",

"agg1" : 1,

"post1" : 3000.0

}, {

"COUNTRY" : "Aruba",

"agg1" : 1,

"post1" : 3000.0

}, {

"COUNTRY" : "Azerbaijan",

"agg1" : 1,

"post1" : 3000.0

}, {

"COUNTRY" : "China",

"agg1" : 1,

"post1" : 3000.0

}, {

"COUNTRY" : "Czech Republic",

"agg1" : 1,

"post1" : 3000.0

} ]

but when the order of fields is switched it gives the right result.

and there is No problem with multiplication no matter what the order is.

Also, I did the same test with type timeseries it works ok.

Could anybody please explain why this query is not working?

Thanks.

Best,

Hamit

This result seems ok to me, you’re ordering by “3000 / agg1” which will be greatest when agg1 is smallest. Your limit of 5 means you’re getting rows with the 5 smallest values of agg1.

Hi Gian,
Yes you are right, I did not think that way.

I am just on a learning curve for different queries.

Thank you.