Searching for any 10-digit number in multiple field where 22000000 records and data size 50GB

Searching for any 10-digit number in multiple field where 22000000 records and data size 50GB

we used regex with indexing but it is still slow

Hi @Akanksha_gogar welcome to the forums and community.

Is the field a number or a string?

What is ‘slow’?
What is the document schema/shape?
What indexes have you tried?

Field type is string

We used regex for search using $regex and created compound index with field1,field2,field3
$or: [
{ field1: { $regex: /^\d{10}$/ } },
{ field2: { $regex: /^\d{10}$/ } },
{ field3: { $regex: /^\d{10}$/ } }
// Add more fields as needed
]

The compound index

is not a usable index for the query parts below:

Read about compound indexes and in particular abount prefix to understand why.