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

This reference topic applies to FQL v4. Go to this page for the latest FQL v10 reference topics.

Copied!
Indexes( [database] )

Description

The Indexes function, when executed with Paginate, returns an array of References for all indexes in the specified child database. If a child database is not specified, the returned index references all belong to the current database.

When a child database is specified, an admin key must be used to call Indexes (server or client keys, or ABAC tokens, cannot be used to access a child database).

Parameters

Parameter Type Definition and Requirements

database

Reference

Optional - A Reference to a child database. If not specified, the current database is used.

Returns

A Set Reference for the available indexes in the specified child database (or the current database if database is not specified).

Examples

  1. The following query lists the References for any indexes (up to the pagination limit) in the current database:

    Copied!
    Paginate(Indexes())
    {
      data: [
        Index("spells_by_element"),
        Index("spellbooks_by_owner"),
        Index("spells_by_spellbook"),
        Index("spells_by_element_and_name"),
        Index("elements_of_spells"),
        Index("letters"),
        Index("people_by_age_first"),
        Index("people_by_last_first"),
        Index("users_by_email"),
        Index("products_by_customer"),
        Index("products_by_store"),
        Index("inventory_by_product"),
        Index("products_by_price_high_to_low"),
        Index("products_by_price_low_to_high"),
        Index("all_customers"),
        Index("all_orders"),
        Index("all_products"),
        Index("all_stores")
      ]
    }
    Query metrics:
    •    bytesIn:    29

    •   bytesOut: 1,386

    • computeOps:     1

    •    readOps:     8

    •   writeOps:     0

    •  readBytes:   964

    • writeBytes:     0

    •  queryTime:  46ms

    •    retries:     0

  2. The following query lists the References for any indexes (up to the pagination limit) in a child database named "child_db":

    Copied!
    Paginate(Indexes(Database('child_db')))
    { data: [] }
    Query metrics:
    •    bytesIn:   48

    •   bytesOut:   24

    • computeOps:    1

    •    readOps:    8

    •   writeOps:    0

    •  readBytes:  363

    • writeBytes:    0

    •  queryTime: 17ms

    •    retries:    0

  3. The following query demonstrates what happens when no indexes exist:

Copied!
Paginate(Indexes())
{ data: [] }
Query metrics:
  •    bytesIn:    29

  •   bytesOut:    24

  • computeOps:     1

  •    readOps:     8

  •   writeOps:     0

  •  readBytes:   208

  • writeBytes:     0

  •  queryTime: 583ms

  •    retries:     0

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!