I am having trouble getting an example of a map reduction to work when the data is distributed across two nodes. I keep documents related to application errors registered on two local ravenDB nodes, documents with an error look like this:
Sample document on node 1, total 6
errors/1/6 { "UniqueId": "c62c7e30-8ec7-45af-88e4-da023d796727", "ApplicationName": "MyAppName" }
Sample document on node 2, total 7
errors/2/6 --Error stored on shard node 2 { "UniqueId": "7e0b0f87-9d75-4e70-9fa0-d64a18bc88dc", "ApplicationName": "MyAppName" }
when i run this query:
public class ApplicationNames : AbstractIndexCreationTask<ErrorDocument, Application> { public ApplicationNames() { Map = errors => from error in errors select new { error.ApplicationName, Count = 1 }; Reduce = results => from error in results group error by new { error.ApplicationName, error.Count } into g select new { g.Key.ApplicationName, Count = g.Sum(x=> x.Count) }; } }
I return 2 results; one with column 6, the second with column 7. I expected that the two results of each fragment would be combined into one result with a count of 13. I'm not sure if I am doing something wrong or if this is not how it should work. I followed this example at http://ravendb.net/documentation/docs-sharding to set up a scalding strategy.
Grant source share