RavenDB's Scripted Index Results
Join the DZone community and get the full member experience.
Join For Freescripted index results (i wish it would have a better name) is a really interesting new feature in ravendb 2.5. as the name implies, it allows you to attach scripts to indexes. those scripts can operate on the results of the indexing.
sounds boring, right? but the options that is opens are nothing but. using scripted index results you can get recursive map/reduce indexes, for example. but we won’t be doing that today. instead, i’ll show how you can enhance entities with additional information from other sources.
our sample database is northwind, and we have defined the following index to get some statistics about our customers:
and we can query it like this:
however, what we want to do is to be able to embed those values inside the company document, so we won’t have to query for it separately. here is how we can use the new scripted index results bundle to do this:
once we have defined that, whenever the index is done, it will run these scripts, and that, in turns, means that this is what our dear alfki looks like:
i’ll leave recursive map/reduce as tidbit for my dear readers
.
Published at DZone with permission of Oren Eini, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Trending
-
Google Becomes A Java Developer's Best Friend: Instantiations Developer Tools Relaunched For Free
-
Conditional Breakpoints: A Guide to Effective Debugging
-
Five Java Books Beginners and Professionals Should Read
-
Cypress Tutorial: A Comprehensive Guide With Examples and Best Practices
Comments