首页 > 解决方案 > RavenDB 查询 ProjectFromIndexFieldsInto 限制 15 结果

问题描述

我对股票有以下指数定义

 public class GetStockListForCustomerIndex : AbstractIndexCreationTask<CustomerStock, GetStockListForCustomerIndex.Result>
{
    public GetStockListForCustomerIndex()
    {
        this.Map = docs => from d in docs

                           from i in d.Items
                           select new Result
                           {
                               Id = i.Id,
                               Country = d.Country,
                               CustomerNumber = d.CustomerNumber,
                               Type = d.Type,
                               ItemNumber = i.ItemNumber,
                               ItemName = i.ItemName,
                               ItemNameSortingField = i.ItemName,
                               UnitCost = i.UnitCost,
                               Quantity = i.Quantity,
                               ReservationDate = i.ReservationStartDate,
                               Threshold = i.Threshold,
                               AvailableQuantity = i.Available,
                               QuantityLeft = i.QuantityLeft,
                               Reserved = i.Reserved,
                               AlwaysOne = 1,
                               Currency = i.Currency
                           };

        this.Index(x => x.ItemNumber, FieldIndexing.Analyzed);

        this.Index(x => x.ItemName, FieldIndexing.Analyzed);

        this.Store(x => x.Id, FieldStorage.Yes);

        this.Store(x => x.Country, FieldStorage.Yes);

        this.Store(x => x.CustomerNumber, FieldStorage.Yes);

        this.Store(x => x.Type, FieldStorage.Yes);

        this.Store(x => x.ItemNumber, FieldStorage.Yes);

        this.Store(x => x.ItemName, FieldStorage.Yes);

        this.Store(x => x.ItemNameSortingField, FieldStorage.Yes);

        this.Store(x => x.UnitCost, FieldStorage.Yes);

        this.Store(x => x.Quantity, FieldStorage.Yes);

        this.Store(x => x.ReservationDate, FieldStorage.Yes);

        this.Store(x => x.Threshold, FieldStorage.Yes);

        this.Store(x => x.AvailableQuantity, FieldStorage.Yes);

        this.Store(x => x.QuantityLeft, FieldStorage.Yes);

        this.Store(x => x.Reserved, FieldStorage.Yes);

        this.Store(x => x.Currency, FieldStorage.Yes);
    }

    public class Result
    {
        public int Id { get; set; }

        public string Country { get; set; }

        public string CustomerNumber { get; set; }

        public string Type { get; set; }

        public string ItemNumber { get; set; }

        public string ItemName { get; set; }

        public string ItemNameSortingField { get; set; }

        public Threshold Threshold { get; set; }

        public int Quantity { get; set; }

        public int? AvailableQuantity { get; set; }

        public int? QuantityLeft { get; set; }

        public int? Reserved { get; set; }

        public decimal UnitCost { get; set; }

        public DateTime ReservationDate { get; set; }

        public int AlwaysOne { get; set; }

        public string Currency { get; set; }
    }
}

执行以下查询时:

  session.Query<Result>("GetStockListForCustomerIndex").Where(p =>p.CustomerNumber == "860016" && p.Type=="K3")
                        .ProjectFromIndexFieldsInto<Result>().ToList();

结果将返回 15 项,但文档包含 26 项。我正在使用 Ravendb 3.5。当我使用 selectMany 测试相同的查询时,我得到了正确的结果。

编辑似乎我总是得到最多 15 个项目的结果

标签: c#ravendb

解决方案


用于Raven/MaxSimpleIndexOutputsPerDocument重新配置默认限制 15。

您可以在此处找到更多详细信息:https ://ravendb.net/docs/article-page/3.5/csharp/indexes/fanout-indexes


推荐阅读