You will create a new index definition (Countries_Population
) which will return the population sum for each Country
in the World
database. Then you will register this index automatically within the application startup.
Open the
World
project, create a new folder and name itIndexes
.Add a new class to the
Indexes
folder and name itCountries_Population
.Modify the
Countries_Population
class as follows:Modify the
RavenStore
class to call theCreateIndexes()
method:Save the
World
application and press F5 to build it and run it.
You just modified the World
application in order to automatically create the Countries_Poupulation
index on the World
database.
You began by creating the Countries_Poupulation
index definition. This index defines a Map/Reduce
function that retrieves the Population
for each City Id
and then aggregates them by Country Id
.
Then within the RavenStore
class (in World.DAL
), you call the CreateIndexes()
method...