In this tutorial we will review how to export the data of an index to a file.

To accomplish this, we will leverage the browse feature of Algolia.

There is currently no way to export your index data directly from your Algolia Dashboard as indices can potentially be quite large (in the tens of gigabytes for example).

Exporting the index

The browse method, detailed in the Browse index section, allows us to retrieve results beyond the 1,000 default limit. After retrieving them, we’ll need to save them to a file. If you’re using JavaScript, you can leverage the browseAll method that will crawl the whole index and emit events whenever a new chunk of records is fetched.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// composer autoload
require __DIR__ . '/vendor/autoload.php';

// if you are not using composer
// require_once 'path/to/algoliasearch.php';

$client = new \AlgoliaSearch\Client('YourApplicationID', 'YourAdminAPIKey');
$index = $client->initIndex('your_index_name');

$objects = [];

foreach ($index->browse('') as $hit) {
    $objects[] = $hit;
}

file_put_contents('your_filename', json_encode($objects));

Note that we use an empty query as the argument of the browse to indicate that we want to browse all records.

In cases of large indices, you may need to consider “chunking” the data.

Did you find this page helpful?