
Management Studio's Indexes screen
The Management Studio's Indexes screen displays a list of all the available indexes in the database.
An Index
in RavenDB is a map or map and/or reduce/transform query written in LINQ. The Mapping expression gathers the set of data to query. The Reduction function (which is optional) will "reduce" the map by a set of criteria or transformations. Think of map simply as the selector for all the data that your query cares about. The reduce expression is then performed on the map data to group or summarize it.
In RavenDB, Indexes
might have one or more map function; the Reduce
function is not required but an Index
might have only one Reduce
function. When using the RavenDB 2.0, only one Transform
function is permitted and more than one in RavenDB 2.5.
Note
RavenDB Indexes, Map/Reduce/Transform
, will be discussed in detail in Chapter 5, Advanced RavenDB Indexes and Queries.
The general idea is that we create a LINQ query that returns the data elements that should be indexed. RavenDB then does the rest. When a query is performed often enough and you did not explicitly specify the index, RavenDB creates automatically a temporary index. This can be handy and requires no work on our part. We can also define indexes manually. This is typically what can be done in the editing mode of the Indexes tab screen.
Note
The recommended way to create the RavenDB Indexes is to use the .NET API. Which is discussed in detail in Chapter 5, Advanced RavenDB Indexes and Queries.
By default, the Management Studio creates an Index
named Raven/DocumentsByEntityName
for its own use which will not be deleted when the Delete All Indexes button is used to delete all indexes in a database.
Note
Raven is self-healing. If the Raven/DocumentsByEntityName
index is deleted, Raven will recreate it when the server is restarted.
Creating your first Index
The Indexes screen displays the list of all the available indexes for the current database. Each index is displayed in a rectangle where appears the name of the index and a pencil icon which you can use to edit the related Map/Reduce
query to that index.
The toolbar for the Indexes screen contains a button which allows you to create a New Index or a Dynamic Query. Also, you can list the Recent Queries or Delete All Indexes.
You will learn to create an Index directly in the Management Studio using the New button and choosing to create a new Index in the dropdown list. When you click on the index name in the Indexes screen, a query page will load with the ability to query the result of the index.
When creating an index it must have both: a unique Name
and at least one Map
function.