I read Ayende 's blog post on the RavenDB multi- photographic feature and tried to implement it. I can not make it work. What I have is basically the same as the example in the blog post:
class RootDocument { public string Id { get; set; } public string Foo { get; set; } public string Bar { get; set; } } public class ChildDocument { public string Id { get; set; } public string RootId { get; set; } public int Value { get; set; } } class RootsByIdIndex: AbstractMultiMapIndexCreationTask<RootsByIdIndex.Result> { public class Result { public string Id { get; set; } public string Foo { get; set; } public string Bar { get; set; } public int Value { get; set; } } public RootsByIdIndex() { AddMap<ChildDocument>(children => from child in children select new { Id = child.RootId, Foo = (string)null, Bar = (string)null, Value = child.Value }); AddMap<RootDocument>(roots => from root in roots select new { Id = root.Id, Foo = root.Foo, Bar = root.Bar, Value = 0 }); Reduce = results => from result in results group result by result.Id into g select new { Id = g.Key, Foo = g.Select(x => x.Foo).Where(x => x != null).First(), Bar = g.Select(x => x.Bar).Where(x => x != null).First(), Value = g.Sum(x => x.Value) }; } }
An index query always gives me a value of 0 for the Value attribute. A little attempt at the index makes it seem like the ChildDocument card never retrieves any documents.
Should this work in the current stable version of RavenDB (1.0.573)? Or am I doing it wrong?
source share