Q:

Querying MongoDb's custom key & value with Index

I am trying to store key value data in MongoDb. 
Key could be any string and I don't know about it anything more before storing, value could be any type (int, string, array). And I would like to have an index on such key & value.
I was looking on a (Multikey Index) over an array of my key-vals but looks like it can't cover queries over array fields. 
Is it possible to have an index on a custom key & value in mongoDb and make queries with such operations as $exists and $eq and $gte, $lte, $and, $or, $in without COLLSCAN but through an IXSCAN stage?
Or maybe I need another Db for that?

A:

I may have misunderstood your question but I think that this is precisely where MongoDB's strengths are - dealing with different shapes of documents and data types.
So let's say you have to following two documents:
db.test.insertMany([
    {
        key: "test",
        value: [ "some array", 1 ]
    },
    {
        key: 12.7,
        values: "foo"
    }
])

and you create a compound index like this:
db.test.createIndex({
    "key": 1,
    "value": 1
})

then the following query will use that index:
db.test.find({ "key": "test", "value": 1 })

and also more complicated queries will do the same:
db.test.find({ "key": { $exists: true }, "value": { gt: 0 } })

You can verify this by adding a .explain() to the end of the above queries.
UPDATE based on your comment:
You don't need the aggregation framework for that. You can simply do something like this:
db.test.distinct("user_id", { "key": { $exists: true } })

This query is going to use the above index. Moreover it can be made even faster by changing the index definition to include the "user_id" field like this:
db.test.createIndex({
    "key" : 1.0,
    "value" : 1.0,
    "user_id" : 1
})

This, again, can be verified by running the following query:
db.test.explain().distinct("user_id", { "key": { $exists: true } })

