createIndex( )


Creates an index for a data collection.

The index can't be used immediately, as the process of generating the index takes time. You can check whether an index is ready by calling List Indexes.

Note that when an index fails to create, the failed index still occupies a slot. To remove the failed index and free up the slot for a new index, call Drop Index.

Authentication
  • When developing websites or building an app with Blocks, this method may require elevated permissions, depending on the identity of the user calling it and the calling user’s permissions.
  • When building apps without Blocks or for headless projects, you can only call this method directly when authenticated as a Wix app or Wix user identity. When authenticated as a different identity, you can call this method using elevation.
  • Elevation permits users to call methods they typically cannot access. Therefore, you should only use it intentionally and securely.
Permissions
Manage Data Indexes
Manage All Data Resources
Learn more about app permissions.
Method Declaration
Copy
function createIndex(dataCollectionId: string, index: Index): Promise<Index>;
Method Parameters
dataCollectionIdstringRequired

ID of the data collection for which to generate the index.


indexIndexRequired

Details of the index to be created.

Returns
Return Type:Promise<Index>
JavaScript
import { indexes } from "@wix/data"; async function createIndex(dataCollectionId, index) { const response = await indexes.createIndex(dataCollectionId, index); }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?