There is a list of cases in my database:
{ Id: 1, Owner: "guid1", Text: "Question1" } { Id: 2, Owner: "guid1", Text: "Question2" } { Id: 3, Owner: "guid2", Text: "Question3" }
When requesting data, I would also like to have (in my index, the result) the number of cases, each of which has an owner. Therefore, I created a map / reduce index in this collection:
public class RelatedCases { public Guid Owner { get; set; } public int Count { get; set; } } public class RelatedCaseIndex : AbstractMultiMapIndexCreationTask<RelatedCases> { public RelatedCaseIndex() { AddMap<CaseDocument> (c => c.Select(a => new { a.Owner, Count = 1 })); Reduce = result => result .GroupBy(a => a.Owner) .Select(a => new { Owner = a.Key, Count = a.Sum(b => b.Count) }); } }
Now I just donβt know how to create a query to include data from the index. Based on the documentation, I tried something like:
session.Query<CaseDocument>().Customize(a => a.Include ...)
or TransformResults on CaseIndex, which is not working properly.
I know that I can simply request a raven to get a list of all related persons in a separate request, but I would like to do it at a time.
source share