MongoDB Index Creation Configuration Guide
Feature Overview
Within the MongoDB integration pipeline of Qeasy DataHub, index management is a foundational capability that protects both retrieval performance and write stability on the target side. We designed this feature so that users can declare field indexes for a collection through a visual integration task — without logging into the MongoDB instance or writing scripts — and obtain the expected query performance immediately after data aggregation.
The feature is delivered by the built-in MongoDBQueryAdapter, which invokes the native MongoDB createIndex API to create indexes. The current release supports declaring one or more index fields in a single configuration and specifying the sort direction (ascending/descending). Once submitted, the indexes take effect right away.
Usage Scenarios
The typical scenario is: after a user aggregates business data into a MongoDB collection, an index needs to be created on a frequently queried field to accelerate lookups. Common cases include:
- Single-field index: create an ascending index on a business primary key (e.g.
content.FID) to support exact-match queries by primary key. - Compound index: declare multiple field indexes on the same collection so the MongoDB query optimizer can pick the optimal one for combined queries.
- Sort index: for reports or list views that return rows in descending order by a field such as
created_at, build a descending index to reduce sort cost.
Configuration Guide
1. Adapter and API
Use the following adapter and API in a Qeasy integration strategy:
- Adapter:
\Adapter\MongoDB\MongoDBQueryAdapter - API:
createIndex
2. Configuration Example
The JSON snippet below shows how to create an ascending index on the content.FID field of the collection 60dabfe6-8949-3623-a772-c79c2289eba5_ADATA:
{
"data": {
"index1": {
"key": "content.FID",
"sort": "1"
}
},
"collectionName": "60dabfe6-8949-3623-a772-c79c2289eba5_ADATA"
}
For compound indexes, append additional siblings such as index2 and index3 under the data node, each declaring its own key and sort. The platform will invoke createIndex for them in order.
3. Parameter Reference
| Parameter | Type | Required | Description |
|---|---|---|---|
| data | object | Yes | Index configuration object containing one or more index field definitions |
| index1 | object | Yes | Definition of the first index field; can be extended to index2, index3, etc. |
| key | string | Yes | Name of the indexed field; supports nested paths (e.g. content.FID) |
| sort | string | Yes | Sort direction of the index; 1 is ascending, -1 is descending |
| collectionName | string | Yes | Name of the target MongoDB collection; must match exactly |
Important Notes
- Collection must already exist:
createIndexdoes not create a collection. Make sure the target collection is created by an upstream write step before running the index configuration, otherwise the API will raise an error. - Index uniqueness: Repeatedly calling
createIndexon the same field does not recreate the index by default. Ensure that eachkey+sortpair has a clear business meaning and does not collide with an existing index. - Nested field paths: The
keyparameter supports dot-separated nested fields such ascontent.FID. Confirm that the MongoDB version supports indexing embedded document fields and that the document schema is stable, otherwise the index may become invalid. - Execution timing: It is recommended to declare indexes after data aggregation is complete and before query traffic arrives. Creating indexes repeatedly during high-frequency writes adds extra write overhead, so evaluate carefully.
- Sensitive data protection: Collection and field names are metadata. Use business-oriented naming conventions in Qeasy DataHub and avoid exposing internal codes directly.
With the configuration above, users can govern MongoDB indexes without touching the command line, working seamlessly with the other write, query and transformation capabilities of the Qeasy DataHub platform.