concept index in category ravendb

appears as: indexes, n index, indexes, An index, index, index, The index, An index, indices
RavenDB in Action

This is an excerpt from Manning's book RavenDB in Action.

Among other things, RavenDB creates and manages indexes automatically and performs operations in bulk, with varying bulk sizes depending on usage. All of this is done in order to make the database more responsive and to require considerably less maintenance.

We don’t need to go far to come up with an example to demonstrate what a crucial part indexes play in answering queries. This is exactly like going to a library with millions of books and trying to find one book on the thousands of shelves. And when you find that book, you must find the one page out of the hundreds of pages it contains that mentions the topic you’re interested in. If the library has a decent catalog, this will take a matter of minutes. Otherwise, you may spend a whole weekend there before getting to the right book.

Without indexes it’s impossible to find data on anything other than the document ID in RavenDB, and therefore RavenDB becomes just a bloated key/value store. Indexes are the piece of the puzzle that allows rich queries for data to be satisfied efficiently.

Luckily, RavenDB automatically creates and manages indexes for most common queries, but for some cases you’ll have to create indexes yourself. Understanding the query life cycle, when creating indexes manually is required and how those indexes are structured, is going to help you with building complex software with RavenDB.

You can use the Lucene Query Language to query indexes directly via Management Studio, by going to the Indexes tab and clicking the index to query. Let’s query the index you just created to try to find all books with price between 10 to 20 bucks, whose author is Dan Brown, as shown in figure 3.7.

Figure 3.7 Querying an index with the Lucene query language using Management Studio
Query<Book>("BooksIndex")#A Query<Book, BookIndex>()#B #A A query for a Book document(s) made explicitly to an index named BooksIndex #B Same query, to the same index, but using the index class inheriting from AbstractIndexCreationTask. This allows for more-readable and more-maintainable code.