I am pretty sure that this feature is going to be at the very top of the chart when people talk about 2.0 features that they love. This is a feature that we didn’t plan for in 2.0. But we got held up by the memory issues, and I really needed to do something awesome rather than trolling through GBs of dump files. So I decided to give myself a little gift and do a big cool feature as a reward.
Let us imagine the following scenario:
We want to search for invoices based on the customer name. That one is easily enough to do, because you can use the approach outlined here. First do a search on the customer name, then do a search based on the customer id. In most cases, this actually result in better UX, because you have the chance to do more stuff to find the right customer.
That said, a common requirement that also pops up is the need to sort based on the customer name. And that is were things gets complex. You need to do things like multi map reduce, and it get hairy (or get bald, depending if you tear at your hair often or not).
Let us look at another example:
I want to looks for courses that have students named Oren. There are solutions for that, but they aren’t nice.
Here is where we have the awesome feature, indexing related documents:
And now we can query things like this:
And obviously, we can do all the rest, such as sort by it, do full text searching, etc.
What about the more complex example? Students & Courses? This is just as easy:
And then we can query it on:
But wait! Yes, I know what you are thinking. What about updates? RavenDB will take care of all of that for you behind the scenes. When the referenced document change, the value will be reindexed automatically, meaning that you will get the updated value easily.
This feature is going to deal with a lot of pain points that people are currently getting, and I am so excited I can barely sit.