Is it possible to have my map reduce take advantage of the shard key on my collection and only query one shard for results instead of all shards?
If so lets work from the example here. If you change it as follows:
public class InvoicesAmountByDate : AbstractIndexCreationTask<Invoice,
InvoicesAmountByDate.ReduceResult>
{
public class ReduceResult
{
public decimal Amount { get; set; }
public DateTime IssuedAt { get; set; }
public string CompanyId { get;set; } //<--- Does adding this mean we can target shard?
}
public InvoicesAmountByDate()
{
Map = invoices =>
from invoice in invoices
select new
{
invoice.Amount,
invoice.IssuedAt,
invoice.CompanyId //<--- Does adding this mean we can target shard?
};
Reduce = results =>
from result in results
group result by result.IssuedAt
into g
select new
{
Amount = g.Sum(x => x.Amount),
IssuedAt = g.Key,
CompanyId = g.CompanyId //<--- Does adding this mean we can target shard?
};
}
}
Is it possible to set up the map reduce to query invoice amounts by date and company. For example getting the amount by from March 14th, 2012 for only "Company 1" which should be on the Asia server so that only the Asia server is queried?