KOVA
Docs

Views

A view is a name, a source collection, and a pipeline. Reading the view runs the pipeline. It does not copy the documents.

find, count, aggregate, and $text on a view run its pipeline against the source. listCollections reports type: "view". drop removes the view. Dropping the source is refused while a view still reads it.

Create one

The sample load leaves two views on database db. This is the definition of the first:

db.runCommand({
  create: "well_paid",
  viewOn: "emp",
  pipeline: [{ $match: { sal: { $gt: 2000 } } }]
})
db.well_paid.find({}, { ename: 1, sal: 1, _id: 0 })

The rows are employees with salary above 2000, read from emp at query time. Insert a new employee above that line and the view returns them. There is no second copy to refresh.

A view with a disk text index

db.runCommand({
  create: "emp_search",
  viewOn: "emp",
  pipeline: [],
  kova: { inverted: true, analyzer: "en_stem" }
})

kova holds engine options. Keys you add stay on the view. The key this server reads is inverted. true builds the on-disk text index described on Text search.

An inverted view accepts only $match and $project, and the project must keep _id. A $group view is still a valid view. Setting inverted: true on it fails and names the stage. String fields become text, ints become 64-bit integers, doubles become floats, bools stay bools, and dates stay dates. The first type seen for a field stays. A new field extends the schema and the index is rewritten.

The in-memory $text index on ordinary collections stays. inverted does not replace it.

Drop

db.well_paid.drop()

The source collection remains. Drop views that read a collection before you drop the collection.