FQL v4 will be decommissioned on June 30, 2025. Ensure that you complete your migration from FQL v4 to FQL v10 by that date. For more details, review the migration guide. Contact support@fauna.com with any questions. |
Indexes
Solution
The Match
function is used to find matching entries in an index.
-
Indexes created without specifying the
terms
field return all indexedvalues
on the indexed collection:{ data: [ [ 'Alan', 'Perlis', Ref(Collection("People"), "309934841578653184") ], [ 'Alan', 'Turing', Ref(Collection("People"), "309934841578652160") ], [ 'Grace', 'Hopper', Ref(Collection("People"), "309934841576555008") ], [ 'Leslie', 'Lamport', Ref(Collection("People"), "309934841575507456") ], [ 'Marvin', 'Minsky', Ref(Collection("People"), "309934841575506432") ], [ 'Stephen', 'Cook', Ref(Collection("People"), "309934841572360704") ], [ 'Tim', 'Cook', Ref(Collection("People"), "309934841572361728") ] ] }
-
Results from index matches use a specific sorting precedence. The following example uses an index that sorts by
age
descending:{ data: [ [ 119, 'Grace', 'Hopper', Ref(Collection("People"), "309995028361511424") ], [ 107, 'Alan', 'Turing', Ref(Collection("People"), "309995028357317120") ], [ 97, 'Alan', 'Perlis', Ref(Collection("People"), "309995028360462848") ], [ 92, 'Marvin', 'Minsky', Ref(Collection("People"), "309995028352074240") ], [ 81, 'Stephen', 'Cook', Ref(Collection("People"), "309995028351026688") ], [ 80, 'Leslie', 'Lamport', Ref(Collection("People"), "309995028356268544") ], [ 59, 'Tim', 'Cook', Ref(Collection("People"), "309995028351025664") ] ] }
-
For indexes where the
terms
field was defined, entries are located using the indexed terms:{ data: [ [ 'Alan', 'Perlis', Ref(Collection("People"), "309935512027660800") ], [ 'Alan', 'Turing', Ref(Collection("People"), "309935512023466496") ] ] }
-
For indexes where a binding was defined in the
terms
field,Match
works as if the binding was a normal field:{ data: [ [ 'Alan Turing', Ref(Collection("People"), "313624171151098368") ] ] }
-
For indexes where there are multiple
terms
fields defined, theMatch
values must be expressed as an array:{ data: [ [ 'Alan', 'Turing', Ref(Collection("People"), "309995228827222528") ] ] }
Is this article helpful?
Tell Fauna how the article can be improved:
Visit Fauna's forums
or email docs@fauna.com
Thank you for your feedback!