KeplerGrid guide

Create a MongoDB index on one field

Use createIndex() in mongosh or enter the same key in KeplerGrid’s Indexes tab. This example indexes one field on a practice orders collection.

Run a single-field createIndex() command

db.getSiblingDB("keplergrid_index_lab").orders.createIndex({ customerId: 1 })

Load the practice orders first. This command creates the ascending customerId_1 index and returns its name. For a standard index, leave the unique option unset so multiple orders can have the same customer.

db.getSiblingDB("keplergrid_index_lab").orders.getIndexes()

Look for customerId_1 with the key { customerId: 1 } alongside the default _id_ index.

Set up three practice orders

In mongosh, use a development server with an unused practice database and an account allowed to insert documents and create indexes there.

db.getSiblingDB("keplergrid_index_lab").orders.insertMany([
  { _id: "ORDER-1", customerId: "CUST-42", status: "paid" },
  { _id: "ORDER-2", customerId: "CUST-42", status: "pending" },
  { _id: "ORDER-3", customerId: "CUST-81", status: "paid" }
])

Create the index in KeplerGrid

To do the same exercise through KeplerGrid, start with the practice orders before running the shell index command. Open the collection using a Read & write connection with permission to create indexes. Go to Indexes → Create an index and enter this key.

{ "customerId": 1 }

Leave Unique values unchecked. Select Create index, confirm the database and collection, and verify that customerId_1 appears in the index list.

In Documents → Filter, enter the query below and run it. The practice result contains ORDER-1 and ORDER-2. Use Explain on a representative query and data set to see which index MongoDB actually chooses.

{ "customerId": "CUST-42" }

See how to index a filter and sort together, index a subset of a collection, or read the winning plan and query counters.