Hi,
So I am planning on doing some array indexing on data like -
{
"activity": 1234,
"activityDate": "20180922"
"participants": [{
"groupId": 123,
"userId": 44131
},
{
"groupId": 1212,
"userId": 7997
}
]
}
Let’s say the bucket is called tournament.
Initially, I created an index using the following query ->
CREATE INDEX arr_index
ON tournament
(DISTINCT ARRAY v FOR v IN participants END);
Is this a good way to use array index if I expect the following queries -
-
fetch using participant.groupId [ select * from tournament where documentType=“Activity” and any participant in participant SATISFIES participant.groupId=2 END; ]
-
fetch using participant.userId
-
fetch using participant.groupId and participant.userId [ both conditions]
I looked up the query plan for the above queries and the spans array ( which from what I’ve learned is something like the filter for the index service, please correct me if I am wrong here) looked like -
“spans”: [
{
“range”: [
{
“inclusion”: 0,
“low”: “null”
}
]
}
From what I have seen up till now the above should mean I did something wrong .
So, I had the following questions -
- Does the index I shared above just form the index on each individual “participant” value and treats them as a blob of sort? And you cannot use the index for faster access to nested fields in this case?
- Will creating indexes on groupId and userId individually be more beneficial if I want queries like the once I shared above?