Need help with NOT query

Hi,

I am trying to use the NOT filter, but I think I am not getting the correct results. I am using the wikipedia db.

So, for the below query, I am getting count as 39244

{

“queryType” : “groupBy”,

“dataSource” : “wikipedia”,

“granularity” : “day”,

“dimension” : “channel”,

“descending” : “true”,

“intervals” : [“2015-09-12/2015-09-13”],

“aggregations” : [

{

“type” : “count”,

“name” : "Total Count "

}

]

}

Now I am trying to exclude a few “channels” using the filter functionality, but still getting the same count.

{

“queryType” : “groupBy”,

“dataSource” : “wikipedia”,

“granularity” : “day”,

“dimension” : “channel”,

“descending” : “true”,

“intervals” : [“2015-09-12/2015-09-13”],

“aggregations” : [

{

“type” : “count”,

“name” : "Total Count "

}

],

“filter”: {

“type”: “not”,

“field”:

{ “type”: “and”,

“fields”: [

{ “type”: “selector”, “dimension”: “channel”, “value”: “it.wikipedia”},

{ “type”: “selector”, “dimension”: “channel”, “value”: “be.wikipedia”},

]

}

}

}

#it.wikipedia, row_count -> 1317

#be.wikipedia, row_count -> 33

Expected: It should give me less count precisely (39244 - (1317+33)) = 37894

Am I doing anything wrong?

Thanks,

Tushar

The inner filter needs to be an OR:


{ "type": "and",

"fields": [

{ "type": "selector", "dimension": "channel", "value": "it.wikipedia"},

{ "type": "selector", "dimension": "channel", "value": "be.wikipedia"},

]

}

The and filter here wouldn’t match any rows (the channel can only have one value)

Yeah makes sense. But it is still giving me the same count :frowning:

Hi Tushar,

For ‘not in’ query use ‘in’ filter instead of ‘and’ filter.

Try following query it should give you expected results.

{

“queryType” : “groupBy”,

“dataSource” : “wikipedia”,

“granularity” : “day”,

“dimension” : “channel”,

“descending” : “true”,

“intervals” : [“2015-09-12/2015-09-13”],

“aggregations” : [

{

“type” : “count”,

“name” : "Total Count "

}

],

“filter”: {

"type": "not",

"field": 

  { "type": "in", 

     "dimension": "channel",

      "values": ["it.wikipedia", "be.wikipedia"]

  }

}

}

Thank you,

Niraj Dedhia