Using Couchbase Lite Swift, suppose I have a document that looks like this, where clearedProjects
is an array of UUID strings:
// Pseudocode:
Foo {
"clearedProjects": [String]
}
To find all Foo
documents that contain a certain value in clearedProjects
, I run this:
SELECT Meta().id FROM `Foo` WHERE (ARRAY_CONTAINS(`clearedProjects`, "e45a4b6c-9c01-4819-9d38-4dc448149b79"))
If I want to speed up this query with an index, should I use a value index or an array index?
let idxValueConfig = ValueIndexConfiguration(["clearedProjects"])
let idxArrayConfig = ArrayIndexConfiguration("clearedProjects")
// Should I use `idxValueConfig` or `idxArrayConfig` in place of the XXX? -->
try fooCollection.createIndex(withName: "clearedProjectsIndex", config: XXX)
The docs for ArrayIndexConfiguration
state that this type of index is specifically for UNNEST
. Which type of index is best for using ARRAY_CONTAINS
?