Partial lookup in graphql using composite partition index

Hi! I’m using realm sync with partitions in which the user will have different data for every of his devices. I’ve created a composite partition key that looks like this:


This works fine. Owner id is the realm user id. store_id is the Id of the device.

But, I’m also developing a webapp that will allow to check all the records from that user, without the need to set any store/device. That means that I will only filter by this part:


Now, it is a good idea for the queries to use partial lookup like this:

db.collection.find({"user_id": /xxxx/})

Or for this case it would be better if I have a separated owner_id field (with index) and lookup for that field directly when I only need to use that value?

Hi @Mariano_Cano,

I guess you have an index on the user_id field already.

I think you could benefit from this index already with your regex search if you use a prefix expression:

db.collection.find({"user_id": /^owner_id=xxxx/})


I’m not really answering your question but it’s a start.


1 Like