Ravendb Map减少查询一个碎片

时间:2014-01-20 01:41:43

标签: c# mapreduce nosql ravendb

是否可以让我的地图缩小利用我的集合上的分片键,只查询一个分片而不是所有分片?

如果可以,请从示例here开始。如果您按如下方式进行更改:

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?
                 };
    }
}

是否可以设置地图缩小以按日期和公司查询发票金额。例如,从2012年3月14日起仅为“公司1”获取金额,该公司应位于亚洲服务器上,以便仅查询亚洲服务器?

1 个答案:

答案 0 :(得分:0)

默认是这样的,是的。