Question about using unique indexes for Custom Entities
-
Hello BrainCloud Support Team,
I would like to ask about using unique indexes with Custom Entities.
We are currently using Custom Entity with the entityType FOLLOW, and we tried to create an index named test_index with the unique option enabled.
However, the following error occurred:
Error Code: 3010308 Error Message: Error adding custom entity index test_index for entityType FOLLOW Exception: Index cannot be created with 'unique' option as prevents sharding of custom collection. Exception message: Index cannot be created with 'unique' option as prevents sharding of custom collection.We would like to prevent duplicate values for a specific field in this Custom Entity.
Could you please confirm whether Custom Entity indexes support the unique option?
If unique indexes are not supported due to sharding, could you recommend the best alternative approach to enforce uniqueness for a field in Custom Entity?
Thank you.
Best regards,
Gyutae Lee -
Hi @gyutaelee,
Currently, brainCloud blocksuniqueindexes on all custom collections as a blanket safeguard. The check happens unconditionally before the system even evaluates whether your collection is owned or sharded, so it rejects theuniqueoption with that error.We can manually add the unique index for your
FOLLOWcollection on our end. Please send us a request with:- Your
appId - The
entityType(is itFOLLOWonly?) - The field name(s) that need uniqueness
- The desired index name (e.g.,
test_index)
Once we receive your request, we'll add the uniqueness constraint for you directly.
- Your