Query optimisation for unstructured data

I have a collection where the data is highly unstructured. There can be totally different fields in each document.

{a:1,b1,c1}
{d:1,e:1,f:1}

Now how can i query efficiently?
In original scenario common fields can be identified and index can be created but there can be a lot of unknown fields where index can not be created. So, how do we optimise quering so, that it can run efficiently.

Hi @Kaushik_Das2 ,

There are several solutions but the bet one dependant on the specific use case.

There are wild card indexes which allow dynamically index all fields:

There is a nice pattern called the attribute pattern where using a key value arrays allow dynamic attribute indexing:

Thanks
Pavel

Hi @Pavel_Duchovny Thanks for the solution. Just one question that dynamically adding index in all fields will slow down update and insertion. I should expect this behaviour right?

Yep @Kaushik_Das2

it is possible.