I have a database with millions of data. These datas contains names but I have two types of name
Datas with a given name (denomination key)
OR
Datas with a person name (firstName and lastName keys, I don't have a key that concatenates the two in datas)
I would like to create an API which search the query on given name AND person name
For that, I have to search the query on denomination key AND on concatened firstName lastName key
That's why I, firstly, concat firstName and lastName keys into identity key.
Then i would like make an aggregation to match my query on those two keys
aggregate([
{$addFields:{'identite':{$concat:["$lastName",' ',"$firstName"]}}},
{
$match:{
$and:[{
$or : [
{
'denomination':toUpper(MySearchQuery])
},
{
'identite':toUpper(MySearchQuery)
}
]
}
/*Here, i'll be able to add more conditions*/
]
}
}
])
So my question was how to manage indexes in that case ? Did i have to index my concatened key (identity but it does not exist in my datas) and denomination. Or do i have to index firstName, lastName and denomination
And if you have a better solution to make my searh, I take it too
Thanks in advance.