Files
documentdb/docs/v1/indexing.md
T
Guanzhou Songandsajeetharan 5c240146b1 Add Documentations and Deployment Workflow (#187)
* Add doc site

* update deploy workflow

* add gateway doc

* update structure and add gateway doc

* update missing image

---------

Co-authored-by: sajeetharan <sajeetharan@outlook.com>
2025-05-20 11:20:17 -04:00

1.2 KiB

Indexing

Create an Index

DocumentDB uses the documentdb_api.create_indexes_background function, which allows background index creation without disrupting database operations.

The SQL command demonstrates how to create a single field index on age on the patient collection of the documentdb.

SELECT * FROM documentdb_api.create_indexes_background('documentdb', '{ "createIndexes": "patient", "indexes": [{ "key": {"age": 1},"name": "idx_age"}]}');

The SQL command demonstrates how to create a compound index on fields age and registration_year on the patient collection of the documentdb.

SELECT * FROM documentdb_api.create_indexes_background('documentdb', '{ "createIndexes": "patient", "indexes": [{ "key": {"registration_year": 1, "age": 1},"name": "idx_regyr_age"}]}');

Drop an Index

DocumentDB uses the documentdb_api.drop_indexes function, which allows you to remove an existing index from a collection. The SQL command demonstrates how to drop the index named id_ab_1 from the first_collection collection of the documentdb.

CALL documentdb_api.drop_indexes('documentdb', '{"dropIndexes": "patient", "index":"idx_age"}');