Getting error in simple topN query

Hi everyone,

Below is my query for sample json file.I am getting error while querying.

{
“queryType”: “topN”,
“dataSource”: “csvjson”,
“intervals” :[“2018-09-27/2018-09-28”],
“granularity”: “all”,
“dimensions”:“user”,
“metrics”:“count”,
“threshold” : “3”,
“aggregations” :[
{
“type” : “count”,
“name” : “count”
}
]

     }

Below is my error message:-

{
“error” : “Unknown exception”,
“errorMessage” : “Instantiation of [simple type, class io.druid.query.topn.TopNQuery] value failed: null”,
“errorClass” : “com.fasterxml.jackson.databind.JsonMappingException”,
“host” : null
}

and this is my sample json file attached:-

csvjson.json (1.95 KB)

Hey Shivendra,

Both dimension and metric are documented as singular but you have them in your example as plural

http://druid.io/docs/latest/querying/topnquery.html

Hi Dylan,

I just went through that document.I didnt understand what should be put in

"filter": {
    "type": "and",
    "fields": [
      {
        "type": "selector",
        "dimension": "dim1",
        "value": "some_value" <-- what should be written here

And

{
        "type": "selector",
        "dimension": "dim2",
        "value": "some_other_val"  <-- Here also
      }
    ]
  },

"aggregations": [
    {
      "type": "longSum",
      "name": "count",
      "fieldName": "count"
    },
    {
      "type": "doubleSum",
      "name": "some_metric",
      "fieldName": "some_metric"  <-- Here also what should be written
    }
  ],


"postAggregations": [
    {
      "type": "arithmetic",
      "name": "average",
      "fn": "/",
      "fields": [
        {
          "type": "fieldAccess",
          "name": "some_metric",
          "fieldName": "some_metric" <-- here also
        },

 

Hey Shivendra,

I meant that in your original example you have

“dimensions”:“user”,
“metrics”:“count”,

``

try changing this to

“dimension”:“user”,
“metric”:“count”,

``

Ok I will do that.If i got an error then i will let you know.

Its showing nothing only empty brackets.

below is my .json file kindly check and tell me what should be written for topN query.

csvjson.json (1.95 KB)

Hey Shivendra,

If you got no results, it might be because there isn’t data loaded. Try checking the information schema to see if you have tables: SELECT * FROM INFORMATION_SCHEMA.TABLES (in Druid SQL: http://druid.io/docs/latest/querying/sql). If you don’t see anything there, double check your ingestion logs.