How to $lookup with case sensitive values localField, in mongoDB V6

I have two collection and need to performs a left outer join on it. With $lookup is works good but the problem is that the collections come from some API where the value of localField is in lower case and foreignField is in upper case.

How to use $lookup to ignore or to lowerCase the value(s)? I try something but I have no chance. I found a solution but is for a older version of mongodb. If you have any experience please help :slight_smile:

    $lookup: {
      from: 'mycollection',
      localField: 'symbol',
      foreignField: 'index_id',
      as: 'foo',

this can be achieved automated way supporting both case with out touching the data.
Create Case Insensitive index and then try to match it.

//Case Insensitive ID collection 

db.createCollection("caseinsensitive_up2", {
    collation: {
        "locale": "en",
        "strength": 1

db.caseinsensitive_up2.find({}){ _id: "RAMKUMAR", name: "ramkumar" }){ _id: "ramkumar", name: "ramkumar232" }){ _id: "rAmKumar", name: "ramkumar" })

db.caseinsensitive_up2.find({ _id: 'rAmKumar' })

    { _id: 'RAmKuMaR' },
    { name: "ramkumar232" },
    { upsert: true }

The solution:

pretty over complicated :slight_smile: