/// <summary> Creates a new {@link TopFieldCollector} from the given /// arguments. /// /// <p/><b>NOTE</b>: The instances returned by this method /// pre-allocate a full array of length /// <code>numHits</code>. /// /// </summary> /// <param name="sort">the sort criteria (SortFields). /// </param> /// <param name="numHits">the number of results to collect. /// </param> /// <param name="fillFields">specifies whether the actual field values should be returned on /// the results (FieldDoc). /// </param> /// <param name="trackDocScores">specifies whether document scores should be tracked and set on the /// results. Note that if set to false, then the results' scores will /// be set to Float.NaN. Setting this to true affects performance, as /// it incurs the score computation on each competitive result. /// Therefore if document scores are not required by the application, /// it is recommended to set it to false. /// </param> /// <param name="trackMaxScore">specifies whether the query's maxScore should be tracked and set /// on the resulting {@link TopDocs}. Note that if set to false, /// {@link TopDocs#GetMaxScore()} returns Float.NaN. Setting this to /// true affects performance as it incurs the score computation on /// each result. Also, setting this true automatically sets /// <code>trackDocScores</code> to true as well. /// </param> /// <param name="docsScoredInOrder">specifies whether documents are scored in doc Id order or not by /// the given {@link Scorer} in {@link #SetScorer(Scorer)}. /// </param> /// <returns> a {@link TopFieldCollector} instance which will sort the results by /// the sort criteria. /// </returns> /// <throws> IOException </throws> public static TopFieldCollector create(Sort sort, int numHits, bool fillFields, bool trackDocScores, bool trackMaxScore, bool docsScoredInOrder) { if (sort.fields.Length == 0) { throw new System.ArgumentException("Sort must contain at least one field"); } FieldValueHitQueue queue = FieldValueHitQueue.Create(sort.fields, numHits); if (queue.GetComparators().Length == 1) { if (docsScoredInOrder) { if (trackMaxScore) { return(new OneComparatorScoringMaxScoreCollector(queue, numHits, fillFields)); } else if (trackDocScores) { return(new OneComparatorScoringNoMaxScoreCollector(queue, numHits, fillFields)); } else { return(new OneComparatorNonScoringCollector(queue, numHits, fillFields)); } } else { if (trackMaxScore) { return(new OutOfOrderOneComparatorScoringMaxScoreCollector(queue, numHits, fillFields)); } else if (trackDocScores) { return(new OutOfOrderOneComparatorScoringNoMaxScoreCollector(queue, numHits, fillFields)); } else { return(new OutOfOrderOneComparatorNonScoringCollector(queue, numHits, fillFields)); } } } // multiple comparators. if (docsScoredInOrder) { if (trackMaxScore) { return(new MultiComparatorScoringMaxScoreCollector(queue, numHits, fillFields)); } else if (trackDocScores) { return(new MultiComparatorScoringNoMaxScoreCollector(queue, numHits, fillFields)); } else { return(new MultiComparatorNonScoringCollector(queue, numHits, fillFields)); } } else { if (trackMaxScore) { return(new OutOfOrderMultiComparatorScoringMaxScoreCollector(queue, numHits, fillFields)); } else if (trackDocScores) { return(new OutOfOrderMultiComparatorScoringNoMaxScoreCollector(queue, numHits, fillFields)); } else { return(new OutOfOrderMultiComparatorNonScoringCollector(queue, numHits, fillFields)); } } }
public OneComparatorNonScoringCollector(FieldValueHitQueue queue, int numHits, bool fillFields) : base(queue, numHits, fillFields) { comparator = queue.GetComparators()[0]; reverseMul = queue.GetReverseMul()[0]; }
public OneComparatorNonScoringCollector(FieldValueHitQueue queue, int numHits, bool fillFields) : base(queue, numHits, fillFields) { comparator = queue.GetComparators()[0]; reverseMul = queue.GetReverseMul()[0]; }