I’m using $indexOfCP for locating the index of some specific words. Unfortunately, it only returns the first result. I want all the occurrences. Plus, $indexOfCP is case sensitive and I want it to be case-insensitive.
here is an example:
db.inventory.aggregate(
   [
     {
       $project:
          {
            cpLocation: { $indexOfCP: [ "$item", "foo" ] },
          }
      }
   ]
)
{ $indexOfCP: [ "cafeteria", "e" ] } result: 3
 
    