/// <summary> /// Create a new <seealso cref="EarlyTerminatingSortingCollector"/> instance. /// </summary> /// <param name="in"> /// the collector to wrap </param> /// <param name="sort"> /// the sort you are sorting the search results on </param> /// <param name="numDocsToCollect"> /// the number of documents to collect on each segment. When wrapping /// a <seealso cref="TopDocsCollector"/>, this number should be the number of /// hits. </param> public EarlyTerminatingSortingCollector(Collector @in, Sort sort, int numDocsToCollect) { if (numDocsToCollect <= 0) { throw new IllegalStateException("numDocsToCollect must always be > 0, got " + segmentTotalCollect); } this.@in = @in; this.sort = sort; this.numDocsToCollect = numDocsToCollect; }
/// <summary> /// Return a sorted view of <code>reader</code> according to the order /// defined by <code>sort</code>. If the reader is already sorted, this /// method might return the reader as-is. /// </summary> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public static org.apache.lucene.index.AtomicReader wrap(org.apache.lucene.index.AtomicReader reader, org.apache.lucene.search.Sort sort) throws java.io.IOException public static AtomicReader wrap(AtomicReader reader, Sort sort) { return wrap(reader, (new Sorter(sort)).sort(reader)); }
/// <summary> /// Returns {@code true} if the given {@code reader} is sorted by the specified {@code sort}. </summary> public static bool isSorted(AtomicReader reader, Sort sort) { if (reader is SegmentReader) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.apache.lucene.index.SegmentReader segReader = (org.apache.lucene.index.SegmentReader) reader; SegmentReader segReader = (SegmentReader) reader; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.Map<String, String> diagnostics = segReader.getSegmentInfo().info.getDiagnostics(); IDictionary<string, string> diagnostics = segReader.SegmentInfo.info.Diagnostics; if (diagnostics != null && sort.ToString().Equals(diagnostics[SORTER_ID_PROP])) { return true; } } return false; }
/// <summary> /// Create a new {@code MergePolicy} that sorts documents with the given {@code sort}. </summary> public SortingMergePolicy(MergePolicy @in, Sort sort) { this.@in = @in; this.sorter = new Sorter(sort); this.sort = sort; }
/// <summary> /// Create a new <seealso cref="EarlyTerminatingSortingCollector"/> instance. /// </summary> /// <param name="in"> /// the collector to wrap </param> /// <param name="sort"> /// the sort you are sorting the search results on </param> /// <param name="numDocsToCollect"> /// the number of documents to collect on each segment. When wrapping /// a <seealso cref="TopDocsCollector"/>, this number should be the number of /// hits. </param> public EarlyTerminatingSortingCollector(Collector @in, Sort sort, int numDocsToCollect) { if (numDocsToCollect <= 0) { throw new IllegalStateException("numDocsToCollect must always be > 0, got " + segmentTotalCollect); } this.@in = @in; this.sort = sort; this.numDocsToCollect = numDocsToCollect; }