Aggregation API: Making case-insensitive matches
Hi all,
How would you recommend matching activity IDs in a case-insensitive way using the Aggregation API? I'm working on a Drupal 7 module which calls the Aggregation API to pull out statements where an activity ID matches a particular string.
We're in the position where historically the casing might be slightly different in our Learning Locker data which means records aren't returned. For example:
'$match' => array(
'statement.object.id' => 'https://example.org/Test/ABC123'
)
This matches all with an activity ID of https://example.org/Test/ABC123 but none which are stored as https://example.org/test/abc123. There is the added complication that some of the stored statements I'm trying to get at might be a mix of upper and lowercase i.e. https://example.org/Test/aBc123.
At the moment, I've had to write in something which generates multiple versions of an activity ID in different casing combinations (until we can rectify) but this is quite cumbersome and doesn't always cover every casing the stored statement could be.
We're moving onto Learning Locker 6.2.4 and I was hoping to get around this by using the Aggregation API but I'm running into the same thing.
The process I'm going through at the moment is:
- Writing out the Aggregation API call in PHP
- Making a CURL call to Learning Locker 6.2.4
- Getting the data back as JSON and processing
I saw some things online which recommended using a regex in the match statement but it seems like it doesn't work in this instance. Here's one of the really simple ones I've tried:
'$match' => array(
'statement.object.id' => '/^https://example.org/Test/ABC123$/i'
)
But I get nothing back at all in this case (I've tried a couple of different regexes and nothing has returned anything unfortunately). I'm trying to avoid anything like running a mongo command which sets everything to lowercase in the database at the moment.
Has anyone else had this issue and could anyone point me in the right direction?