KeplerGrid guide

Return selected fields with MongoDB projection

A filter chooses documents. A projection chooses fields from those documents. Put each JSON object in its own field in KeplerGrid.

Return a product name and nested price

Load the synthetic inventory. Open keplergrid_inventory.inventory in Documents. To select the notebook, paste this into Filter.

{ "_id": "SKU-100" }

Open Sort & projection, enter this in Projection, and click Run.

{ "name": 1, "pricing.unitPrice": 1, "_id": 0 }

Open JSON view to inspect the result. The price stays inside pricing, and the Decimal128 value remains in Extended JSON.

{
  "name": "Notebook",
  "pricing": { "unitPrice": { "$numberDecimal": "12.50" } }
}

MongoDB includes _id by default. The "_id": 0 entry hides it in this result.

Keep all fields except a few

Use this projection to omit the stock array and the nested currency while keeping the other fields on the same document.

{ "stock": 0, "pricing.currency": 0 }

Choose inclusion or exclusion for ordinary fields. MongoDB lets you exclude _id in an inclusion projection.

Get back to the complete document

Projection applies to the query result and leaves the stored document intact. KeplerGrid opens projected results in read-only form. Clear Projection or set it to {}, then run the query again to see the full document.

Learn to edit and verify a nested BSON value, or compare more MongoDB filters.

For an array field, use projection $slice to return selected elements.

Next, Check a MongoDB covered query with Explain.

Next, Read MongoDB field names with dots or dollar signs using $getField.