.net – 指定索引文档集合排序

我们假设我有以下索引定义:

public class LastSuspensions: AbstractIndexCreationTask<Casino, LastSuspensions.ReduceResult>
    {
        public class ReduceResult
        {
            public string CityId { get; set; }
            public DateTime DateTime { get; set; }
            public string CasinoId { get; set; }
            public IList<Exemption> Exemptions { get; set; }
        }

        public LastSuspensions()
        {
            Map = casinos => from casino in casinos
                             from suspension in casino.Suspensions
                             select new { CityId = casino.CityId, DateTime = suspension.DateTime, CasinoId = casino.Id, Exemptions = suspension.Exemptions };

            Store(x => x.CityId, FieldStorage.Yes);
            Store(x => x.DateTime, FieldStorage.Yes);
            Store(x => x.CasinoId, FieldStorage.Yes);
            Store(x => x.Exemptions, FieldStorage.Yes);
        }

有没有办法指定我想让Exemptions集合按其属性之一进行排序?

最佳答案 您无需在这些字段上调用Store.

而且,由于您要将整个异常集合拉出来,作为加载文档的一部分,在客户端上进行排序没有实际的额外成本.

点赞