#
Indices
Indices optimize queries. When you have a large number of entries in a collection, queries will begin to take longer to process. When this happens, create an index for the query.
You may only create indices for entries with JSON values.
#
The Lookup And Sort Properties
Each index consists of a lookup property and a sort property. The lookup property is the property that is indexed for fast lookups. The sort property determines how results should be sorted.
#
Creating An Index
- Navigate to a workspace and select DB.
- Navigate to the database that contains the collection for which you want to create an index.
- Navigate to the collection for which you want to create an index.
- Select Add An Index.
- Enter the
Lookup property . - Enter the
Sort property . - Select Create.
curl -XPOST "https://db.dashkite.io/db/{db}/collections/{collection}/indices" \
-H "Authorization: {api-key}" \
-H 'Content-Type: application/json' \
-d '{"lookup": "{lookup}", "sort": "{sort}" }'
#
Checking The Status Of An Index
- Navigate to a workspace and select DB.
- Navigate to the database that contains the collection to which the index belongs.
- Navigate to the collection to which the index belongs.
- The status of the index will be displayed alongside the index description.
curl -XGET "https://db.dashkite.io/db/{db}/collections/{collection}/indices?{lookup}&{sort}" \
-H "Authorization: {api-key}" \
-H 'Accept: application/json'
The request will return a JSON object describing the status. If the index is ready, the status will be ready
.
#
Listing Indices
- Navigate to a workspace and select DB.
- Navigate to the database that contains the collection to which the index belongs.
- Navigate to the collection for which you want to view the indices.
curl -XGET "https://db.dashkite.io/db/{db}/collections/{collection}/indices" \
-H "Authorization: {api-key}" \
-H 'Accept: application/json'
#
Removing An Index
- Navigate to a workspace and select DB.
- Navigate to the database that contains the collection to which the index belongs.
- Navigate to the collection to which the index belongs.
- Navigate to the index description that matches the index you wish to remove.
- Select Delete.
- Select Delete Index to confirm.
curl -XDELETE "https://db.dashkite.io/db/{db}/collections/{collection}/indices?{lookup}&{sort}" \
-H "Authorization: {api-key}"