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"), "310011992898273792") ], [ 'Alan', 'Turing', Ref(Collection("People"), "310011992901419520") ], [ 'Grace', 'Hopper', Ref(Collection("People"), "310011992897225216") ], [ 'Leslie', 'Lamport', Ref(Collection("People"), "310011992895129088") ], [ 'Marvin', 'Minsky', Ref(Collection("People"), "310011992895128064") ], [ 'Stephen', 'Cook', Ref(Collection("People"), "310011992891983360") ], [ 'Tim', 'Cook', Ref(Collection("People"), "310011992891982336") ] ] }
-
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"), "310012262298419712") ], [ 107, 'Alan', 'Turing', Ref(Collection("People"), "310012262299469312") ], [ 97, 'Alan', 'Perlis', Ref(Collection("People"), "310012262299468288") ], [ 92, 'Marvin', 'Minsky', Ref(Collection("People"), "310012262295273984") ], [ 81, 'Stephen', 'Cook', Ref(Collection("People"), "310012262292129280") ], [ 80, 'Leslie', 'Lamport', Ref(Collection("People"), "310012262296322560") ], [ 59, 'Tim', 'Cook', Ref(Collection("People"), "310012262292128256") ] ] }
-
For indexes where the
terms
field was defined, entries are located using the indexed terms:{ data: [ [ 'Alan', 'Perlis', Ref(Collection("People"), "310012851960939008") ], [ 'Alan', 'Turing', Ref(Collection("People"), "310012851957793280") ] ] }
-
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"), "310011445570961920") ] ] }
-
For indexes where there are multiple
terms
fields defined, theMatch
values must be expressed as an array:{ data: [ [ 'Alan', 'Turing', Ref(Collection("People"), "310005407260082688") ] ] }
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!