The Fauna service will be ending on May 30, 2025.

For more information on the service wind down, see our announcement and the Fauna Service End-of-Life FAQ.

Rename an index

Problem

You need to rename an index within the current database.

Solution

Use the Update function:

Copied!
Update(Index('all_people'), { name: 'all_of_the_people' })
{
  ref: Index("all_of_the_people"),
  ts: 1631835755950000,
  active: true,
  serialized: true,
  name: 'all_of_the_people',
  source: Collection("People"),
  values: [
    { field: [ 'data', 'first' ] },
    { field: [ 'data', 'last' ] },
    { field: [ 'ref' ] }
  ],
  partitions: 8
}
Query metrics:
  •    bytesIn:    82

  •   bytesOut:   350

  • computeOps:     1

  •    readOps:     0

  •   writeOps:     1

  •  readBytes: 1,587

  • writeBytes:   486

  •  queryTime: 381ms

  •    retries:     0

Discussion

You can rename an index, add metadata, or change the unique field. However, you cannot change an index’s terms or values definitions after the index has been created.

If you need to modify an index’s terms or values definition, you should create a new index with the new definition, then rename the old index out of the way, and rename the new index to use the original name of the old index.

If you change unique to true, any existing duplicate items in the index are not automatically removed.

\