RavenDB has a lot features to create indexes. In the previous chapter, we learned how to create an index and define its Map
and Reduce
functions using the PutIndex()
method and the IndexDefinitionBuilder
class. But there is a better way to do this by using the AbstractIndexCreationTask
class and using the CreateIndex()
method to submit the index to the server.
The AbstractIndexCreationTask
class is an abstract generic class. That means no object of this class can be instantiated, but can only make derivations of this class. Also as it is a generic class, it requires the document type to be specified and optionally a ReduceResult
type class.
Querying the RavenDB indexes created using the AbstractIndexCreationTask
class is the same as the indexes created using the PutIndex()
method. You can either let RavenDB decide which index to use, or instruct it to use a specific index by explicitly specifying the index name while querying.