Search by many fields at any combination

my document have 100 fields
i require find documents by 30 fields at ANY COMBINATION (ex field1+field17, field20+filed5+filed3…)
mongo use full scan in 99% of same search and use 1 index by date

i create indexes(60) for most popular queries, but now i have index limits and indexes size=data size

any hint for organization complex search? full scan is very slow

Hi @_N_A37 welcome to the community!

100 fields is a lot, and your search criteria is difficult to execute with ordinary schema design.

One possible solution is to use the attribute pattern. In short, instead of having documents like this:

{
  _id: 1,
  field_1: x,
  field_2: y,
  field_3: z.
  ...
}

using the attribute pattern means refactoring it to look like this:

{
  _id: 1,
  attr: [
    key: 'field_1', value: x,
    key: 'field_2', value: y,
    key: 'field_3', value: z,
    ...
  ]
}

You can then create an index for this document like:

db.collection.createIndex({'attr.key': 1, 'attr.value': 1})

However note that this is just one possible solution, and depending on your intended use case it may or may not be applicable to you.

If you require further help, could you post:

Best regards
Kevin