RavenDb 报错 has already produced 16 map results for a source document 解决方案

今天发现 RAVenDb 数据库报告错误

Index 'OrderTicketIssueReportIndex' has already produced 16 map results for a source document 'ff0ff6ed-2eab-4fba-8a61-a1b85d9e14cb', while the allowed max number of outputs is 15 per one document. Please verify this index definition and consider a re-design of your entities or index.

 

经过研究, Oren Eini 给出原因和解决方案, 

通过 RavenDb Studio 解决方法:

Go to Add > Max Inputs in the index edit screen.

 

通过代码解决的方案, 在建立索引时, 添加属性:

 1    public class OrderTicketIssueReportIndex : AbstractIndexCreationTask<Order>
 2    {
 3        public OrderTicketIssueReportIndex()
 4        {
 5            MaxIndexOutputsPerDocument = 300; // 通过这个设置, 让服务器索引每文档内子对象超过16个的默认限制
 6 
 7            Map = orders =>
 8                from order in orders
 9                from itin in order.Itineraries
10                where string.IsNullOrEmpty(itin.TicketNumber) == false && itin.PurchaseIssueId.HasValue
11                let firstItin = (from i in order.Itineraries
12                                 where i.TicketNumber == itin.TicketNumber
13                                 orderby i.Flight.DepartureDate ascending
14                                 select i).FirstOrDefault()
15                let purchaseIssue = LoadDocument<PurchaseIssue>(itin.PurchaseIssueId.ToString())
16                select new OrderTicketIssueReportIndexModel
17                {
18                    PlaceOrderTime = order.PlaceOrderTime,
19                    DepartureDate      = itin.Flight.DepartureDate,

 

posted @ 2018-09-30 12:45  nepton  阅读(133)  评论(0编辑  收藏  举报