No.
You will need to have saved at least one record record into it at the point of creation as shown below:
const algoliasearch = require('algoliasearch')
// Connect and authenticate with your Algolia app
const client = algoliasearch('OA5TOH2VFB', 'YourWriteAPIKey')
// Create a new index and add a record
const index = client.initIndex('test_index')
const record = { objectID: 1, name: 'test_record' }
index.saveObject(record).wait()
// Search the index and print the results
index
.search('test_record')
.then(({ hits }) => console.log(hits[0]))
Just using the initIndex
method standalone will not create an empty index.
The initIndex
method doesn’t create a new index on Algolia’s servers. It creates an index object you can interact with—for example, to add records.