# 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.

# 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

  1. Navigate to a workspace and select DB.
  2. Navigate to the database that contains the collection for which you want to create an index.
  3. Navigate to the collection for which you want to create an index.
  4. Select Add An Index.
  5. Enter the Lookup property.
  6. Enter the Sort property.
  7. Select Create.

Create Index Screenshot
Create Index Screenshot

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}" }'  
Parameter Description
db The database address. You can get the database address from the Web app or from the API response when you create the database.
collection The collection byname.
api-key Your API key, which allows you to access your databases. You can get your API key from the Web application.
lookup The lookup property for the index.
sort The sort property for the index.

# Checking The Status Of An Index

  1. Navigate to a workspace and select DB.
  2. Navigate to the database that contains the collection to which the index belongs.
  3. Navigate to the collection to which the index belongs.
  4. 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.

Parameter Description
db The database address. You can get the database address from the Web app or from the API response when you create the database.
collection The collection byname.
api-key Your API key, which allows you to access your databases. You can get your API key from the Web application.
lookup The lookup property for the index.
sort The sort property for the index.

# Listing Indices

  1. Navigate to a workspace and select DB.
  2. Navigate to the database that contains the collection to which the index belongs.
  3. 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'
Parameter Description
db The database address. You can get the database address from the Web app or from the API response when you create the database.
collection The collection byname.
api-key Your API key, which allows you to access your databases. You can get your API key from the Web application.

# Removing An Index

  1. Navigate to a workspace and select DB.
  2. Navigate to the database that contains the collection to which the index belongs.
  3. Navigate to the collection to which the index belongs.
  4. Navigate to the index description that matches the index you wish to remove.
  5. Select Delete.
  6. Select Delete Index to confirm.
curl -XDELETE "https://db.dashkite.io/db/{db}/collections/{collection}/indices?{lookup}&{sort}" \
    -H "Authorization: {api-key}"
Parameter Description
db The database address. You can get the database address from the Web app or from the API response when you create the database.
collection The collection byname.
api-key Your API key, which allows you to access your databases. You can get your API key from the Web application.
lookup The lookup property for the index.
sort The sort property for the index.