I have a MongoDB collection with various data in it. (about millions)
These data have a data struct like {k: {a:1,b:2,c:{},...}}
and I don't know extactly what in it.
Now I wanna do a counting on this collection to return me the total elements in the collection that k
is not empty by using {k:{$exists:true}}
but that's turns out very slow ...
Then I add an index on k
and trying to query by : {k:{$gt:{}}
but that's not return the correct results.
So, how to do this counting on the collection now?
Note that I don't know the data structure of k
.