Ejemplo n.º 1
0
 public OneComparatorNonScoringCollector(FieldValueHitQueue queue, int numHits, bool fillFields) : base(queue, numHits, fillFields)
 {
     comparator = queue.GetComparators()[0];
     reverseMul = queue.GetReverseMul()[0];
 }
Ejemplo n.º 2
0
        /// <summary> Creates a new <see cref="TopFieldCollector" /> from the given
        /// arguments.
        ///
        /// <p/><b>NOTE</b>: The instances returned by this method
        /// pre-allocate a full array of length
        /// <c>numHits</c>.
        ///
        /// </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 <see cref="TopDocs" />. Note that if set to false,
        /// <see cref="TopDocs.MaxScore" /> returns Float.NaN. Setting this to
        /// true affects performance as it incurs the score computation on
        /// each result. Also, setting this true automatically sets
        /// <c>trackDocScores</c> to true as well.
        /// </param>
        /// <param name="docsScoredInOrder">specifies whether documents are scored in doc Id order or not by
        /// the given <see cref="Scorer" /> in <see cref="Collector.SetScorer(Scorer)" />.
        /// </param>
        /// <returns> a <see cref="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));
                }
            }
        }