/// <summary> Allows redefinition of sort fields if they are <code>null</code>. /// This is to handle the case using ParallelMultiSearcher where the /// original list contains AUTO and we don't know the actual sort /// type until the values come back. The fields can only be set once. /// This method is thread safe. /// </summary> /// <param name="">fields /// </param> internal virtual void SetFields(SortField[] fields) { lock (this) { if (this.fields == null) { this.fields = fields; this.collators = HasCollators(fields); } } }
/// <summary>Creates one of these objects.</summary> /// <param name="totalHits"> Total number of hits for the query. /// </param> /// <param name="scoreDocs"> The top hits for the query. /// </param> /// <param name="fields"> The sort criteria used to find the top hits. /// </param> internal TopFieldDocs(int totalHits, ScoreDoc[] scoreDocs, SortField[] fields):base(totalHits, scoreDocs) { this.fields = fields; }
/// <summary>Sets the sort to the given criteria in succession. </summary> public virtual void SetSort(SortField[] fields) { this.fields = fields; }
/// <summary>Sets the sort to the given criteria. </summary> public virtual void SetSort(SortField field) { this.fields = new SortField[]{field}; }
/// <summary>Sets the sort to the terms in each Field in succession. </summary> public virtual void SetSort(System.String[] fieldnames) { int n = fieldnames.Length; SortField[] nfields = new SortField[n]; for (int i = 0; i < n; ++i) { nfields[i] = new SortField(fieldnames[i], SortField.AUTO); } fields = nfields; }
/// <summary>Sets the sort to the terms in <code>Field</code> possibly in reverse, /// then by index order (document number). /// </summary> public virtual void SetSort(System.String field, bool reverse) { SortField[] nfields = new SortField[]{new SortField(field, SortField.AUTO, reverse), SortField.FIELD_DOC}; fields = nfields; }
/// <summary>Sorts in succession by the criteria in each SortField. </summary> public Sort(SortField[] fields) { SetSort(fields); }
/// <summary>Sorts by the criteria in the given SortField. </summary> public Sort(SortField field) { SetSort(field); }
/// <summary> Creates a hit queue sorted by the given list of fields.</summary> /// <param name="reader"> Index to use. /// </param> /// <param name="fields">Field names, in priority order (highest priority first). Cannot be <code>null</code> or empty. /// </param> /// <param name="size"> The number of hits to retain. Must be greater than zero. /// </param> /// <throws> IOException </throws> internal FieldSortedHitQueue(Monodoc.Lucene.Net.Index.IndexReader reader, SortField[] fields, int size) { int n = fields.Length; comparators = new ScoreDocComparator[n]; this.fields = new SortField[n]; for (int i = 0; i < n; ++i) { System.String fieldname = fields[i].GetField(); comparators[i] = GetCachedComparator(reader, fieldname, fields[i].GetType(), fields[i].GetLocale(), fields[i].GetFactory()); this.fields[i] = new SortField(fieldname, comparators[i].SortType(), fields[i].GetReverse()); } Initialize(size); }
/// <summary>Sets the sort to the given criteria. </summary> public virtual void SetSort(SortField field) { this.fields = new SortField[] { field }; }
/// <summary>Sets the sort to the terms in <code>Field</code> possibly in reverse, /// then by index order (document number). /// </summary> public virtual void SetSort(System.String field, bool reverse) { SortField[] nfields = new SortField[] { new SortField(field, SortField.AUTO, reverse), SortField.FIELD_DOC }; fields = nfields; }
/// <summary>Returns an array of collators, possibly <code>null</code>. The collators /// correspond to any SortFields which were given a specific locale. /// </summary> /// <param name="fields">Array of sort fields. /// </param> /// <returns> Array, possibly <code>null</code>. /// </returns> private System.Globalization.CompareInfo[] HasCollators(SortField[] fields) { if (fields == null) return null; System.Globalization.CompareInfo[] ret = new System.Globalization.CompareInfo[fields.Length]; for (int i = 0; i < fields.Length; ++i) { System.Globalization.CultureInfo locale = fields[i].GetLocale(); if (locale != null) ret[i] = locale.CompareInfo; } return ret; }
/// <summary> Creates a hit queue sorted by the given list of fields.</summary> /// <param name="fields">Field names, in priority order (highest priority first). /// </param> /// <param name="size"> The number of hits to retain. Must be greater than zero. /// </param> /// <throws> IOException </throws> internal FieldDocSortedHitQueue(SortField[] fields, int size) { this.fields = fields; this.collators = HasCollators(fields); Initialize(size); }