I have documents (PLAYS) of the following form that I need to get:
{
"id": "play1",
"ownerID": "owner1",
"orgID": "20071513",
"type": "play"
}
{
"id": "play2",
"ownerID": "owner2",
"orgID": "20071513",
"type": "play"
}
And also documents like this in the same bucket:
{
"teamID": "1234",
"playID": "play1",
"type": "mapping"
}
{
"teamID": "1234",
"playID": "play2"
"type": "mapping"
}
And I basically need to query and get all plays for a given ownerID, as well as any plays for a given teamID (which mappings are defined in the second type of document). So some sort of a join on plays where mapping.playID=play.id, and UNION that will plays where ownerID=(some provided owner). I’m unsure if I’m thinking about it totally wrong, if I have the right indexes, etc. I have created the following secondary indexes:
CREATE INDEX idx_play ON default (type) WHERE type = "play";
CREATE INDEX idx_mapping ON default (type) WHERE type = "mapping";
When I query, I want to provide the ownerID “owner1” and the teamID “1234”, so I should get back “play1” and “play2”, because I am the owner of play1, and play2 is associated with my teamID.