Solution was to use
OPTIONS {indexHint: @carIndex}query := `
LET results = FLATTEN(
FOR doc IN @@collectionName01
FILTER @brand == doc.name
RETURN doc.cars)
FOR doc IN @@collectionName02 OPTIONS {indexHint: @carIndex}
FILTER results ANY IN doc.cars
RETURN doc
bindVars := map[string]interface{}{
"@collectionName01": Brand_Collection,
"brand": brand,
"@collectionName02": Car_Collection,
"carIndex": Car_Index,
}
However I was informed by the Arango team that
ANY IN cannot utilize a regular index. This is only supported by
ArangoSearch. So the proper way of writing this is:
query := `
FOR doc1 IN @@collectionName01 FILTER @brand == doc1.name
FOR doc2 IN @@collectionName02
FILTER doc1.cars ANY IN doc2.cars
RETURN doc2`
bindVars := map[string]interface{}{
"@collectionName01": Brand_Collection,
"brand": brand,
"@collectionName02": Car_Collection,
}