Copy or move an index

Copies or moves (renames) an index within the same Algolia application.

  • Existing destination indices are overwritten, except for their analytics data.
  • If the destination index doesn’t exist yet, it’ll be created.
  • This operation is resource-intensive.

Copy

  • Copying a source index that doesn’t exist creates a new index with 0 records and default settings.
  • The API keys of the source index are merged with the existing keys in the destination index.
  • You can’t copy the enableReRanking, mode, and replicas settings.
  • You can’t copy to a destination index that already has replicas.
  • Be aware of the size limits.
  • Related guide: Copy indices

Move

  • Moving a source index that doesn’t exist is ignored without returning an error.
  • When moving an index, the analytics data keeps its original name, and a new set of analytics data is started for the new name. To access the original analytics in the dashboard, create an index with the original name.
  • If the destination index has replicas, moving will overwrite the existing index and copy the data to the replica indices.
  • Related guide: Move indices.

This operation is subject to indexing rate limits.

Usage

Required ACL: addObject
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import "github.com/algolia/algoliasearch-client-go/v4/algolia/search"

client, err := search.NewClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY")
if err != nil {
  // The client can fail to initialize if you pass an invalid parameter.
  panic(err)
}

response, err := client.OperationIndex(client.NewApiOperationIndexRequest(
  "<SOURCE_INDEX_NAME>",
  search.NewEmptyOperationIndexParams().SetOperation(search.OperationType("move")).SetDestination("<DESTINATION_INDEX_NAME>").SetScope(
    []search.ScopeType{search.ScopeType("rules"), search.ScopeType("settings")}),
))
if err != nil {
  // handle the eventual error
  panic(err)
}
Did you find this page helpful?
Go API clients v4