Specify the sorting of the collection of index documents

Suppose I have the following index definition:

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

Is there a way to indicate that I want the Exemptions collection to be sorted by one of its properties?

+4
source share
2 answers

You do not need to call Store in these fields. And since you are going to pull the entire assembly of exceptions as part of loading the document, there is no real additional cost for sorting on the client.

+2
source

The Exemption class must implement the IComparable interface. The IComparable interface defines the CompareTo (T) method, which determines the sort order of the implementation type instances. Here you can find here as well as here .

I hope this will be helpful.

Hello Evgenia

0
source

Source: https://habr.com/ru/post/1388569/


All Articles