Add support for UUID datatypes in Atlas Search
Currently, UUID is not one of the supported datatypes for Atlas Search. This is a feature request to add support for UUID datatypes in Atlas Search.
This work is now complete. Update your search index to:
1. Index fields using the uuid field mapping type
2. Query using the equals or in operators
3. You can also sort on UUID fields
-
Thiago commented
any updates on this?
-
Volodymyr Osadchuk commented
We also use UUID, as a GUID representation, and would like to use the Atlas search on filtered records by UUID collection.
However, according to https://www.mongodb.com/community/forums/t/search-index-filtering/195825, we should include UUID in the search index.P.S. We have more than 10M records, so without filter, or with post-filter search is quering so long...
-
Ben commented
I use UUIDs across various services and databases and for supporting public API interactions.
The implementation independence from Mongo and commoness in web apps makes them a valuable identifer tool and therefore I feel they should be supported within Mongos indexing capabilities.
I mean, if you can index a date object but not a UUID binary, then like .. wut?
It would be great to be able to track the progression of it, such as when we can expect to see it supported.. are we talking mongths or longer?
-
Daniel Oliveira commented
Thank you @Erich!
For anyone who needs, here is a trigger to add the string version of UUID:
exports = async function (changeEvent) {
const doc = changeEvent.fullDocument;
const id = changeEvent.documentKey._id;
const searchId = id.toHex().replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/, '$1-$2-$3-$4-$5');
const collection = ...;
collection
.updateOne(
{ _id: id },
{
$set: {
'searchId': searchId
}
}
);
} -
Erich commented
@Daniel, the only workaround I've found is to store a string version of the UUID and index that in your search index until this is supported. I wish this would get more focus as it's a real issue for my clients.
-
Daniel Oliveira commented
Is there any workaround?
-
Sameer commented
What is the status of this? If this is being tracked, can someone link this to jira ticket please :)