Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
RavenDB 2.x Beginner's Guide

You're reading from  RavenDB 2.x Beginner's Guide

Product type Book
Published in Sep 2013
Publisher Packt
ISBN-13 9781783283798
Pages 356 pages
Edition 1st Edition
Languages
Author (1):
Khaled Tannir Khaled Tannir
Profile icon Khaled Tannir

Table of Contents (21) Chapters

RavenDB 2.x Beginner's Guide
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Getting Started with RavenDB RavenDB Management Studio RavenDB.NET Client API RavenDB Indexes and Queries Advanced RavenDB Indexes and Queries Advanced RavenDB Document Capabilities RavenDB Administration Deploying RavenDB Scaling-out RavenDB RavenDB Profiling RavenDB HTTP API Putting It All Together Pop Quiz Answers Index

Time for action – creating indexes using the ResultReduce class


We will create a new index which will aggregate the World database to make a count of Cities that have the same name in different countries and return the CountryId key for each city as a single document. The following screenshot illustrates the expected result:

  1. Start Visual Studio and open the RavenDB_CH05 solution.

  2. Add a new class to the project, name it Cities_SameName and add the following code snippet:

    Tip

    We named the embedded class ReduceResult by convention. You can choose any other name for this class and place it outside the index class.

    We could use a String type in the ReduceResult class to store the document ID CountriesId (which is a string type), but we choose to create a second embedded class, for learning purposes and show that it is possible to create more complex structure.

  3. Add a default constructor to the Cities_SameName class and within this constructor add the index Map function using the following code snippet...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}