コード例 #1
0
ファイル: Range.cs プロジェクト: wwb/lucenenet
 /// <summary>
 /// Returns a new <see cref="Filter"/> accepting only documents
 ///  in this range.  This filter is not general-purpose;
 ///  you should either use it with <see cref="DrillSideways"/> by
 ///  adding it to <see cref="DrillDownQuery.Add"/>, or pass it to
 ///  <see cref="Search.FilteredQuery"/> using its
 ///  <see cref="Search.FilteredQuery.QUERY_FIRST_FILTER_STRATEGY"/>.  If the
 ///  <see cref="ValueSource"/> is static, e.g. an indexed numeric
 ///  field, then it may be more efficient to use <see cref="Search.NumericRangeFilter"/>.
 /// </summary>
 public virtual Filter GetFilter(ValueSource valueSource)
 {
     return(GetFilter(null, valueSource));
 }
コード例 #2
0
 public DrillSidewaysAnonymousInnerClassHelper2(TestRangeFacetCounts testRangeFacetCounts, IndexSearcher indexSearcher, FacetsConfig facetsConfig, TaxonomyReader org, ValueSource valueSource, DoubleRange[] doubleRanges, Filter filter)
     : base(indexSearcher, facetsConfig, org)
 {
     this.outerInstance = outerInstance;
     this.vs = valueSource;
     this.ranges = doubleRanges;
     this.fastMatchFilter = filter;
 }
コード例 #3
0
ファイル: Range.cs プロジェクト: ChristopherHaws/lucenenet
 /// <summary>
 /// Returns a new <see cref="Filter"/> accepting only documents
 ///  in this range.  This filter is not general-purpose;
 ///  you should either use it with <see cref="DrillSideways"/> by
 ///  adding it to <see cref="DrillDownQuery.Add"/>, or pass it to
 ///  <see cref="Search.FilteredQuery"/> using its 
 ///  <see cref="Search.FilteredQuery.QUERY_FIRST_FILTER_STRATEGY"/>.  If the
 ///  <see cref="ValueSource"/> is static, e.g. an indexed numeric
 ///  field, then it may be more efficient to use <see cref="Search.NumericRangeFilter"/>. 
 /// </summary>
 public virtual Filter GetFilter(ValueSource valueSource)
 {
     return GetFilter(null, valueSource);
 }
コード例 #4
0
ファイル: Range.cs プロジェクト: wwb/lucenenet
 /// <summary>
 /// Returns a new <see cref="Filter"/> accepting only documents
 /// in this range.  This filter is not general-purpose;
 /// you should either use it with <see cref="DrillSideways"/> by
 /// adding it to <see cref="DrillDownQuery.Add"/>, or pass it to
 /// <see cref="Search.FilteredQuery"/> using its
 /// <see cref="Search.FilteredQuery.QUERY_FIRST_FILTER_STRATEGY"/>.
 /// If the <see cref="ValueSource"/> is static, e.g. an indexed numeric
 /// field, then it may be more efficient to use
 /// <see cref="Search.NumericRangeFilter"/>.  The provided <paramref name="fastMatchFilter"/>,
 /// if non-null, will first be consulted, and only if
 /// that is set for each document will the range then be
 /// checked.
 /// </summary>
 public abstract Filter GetFilter(Filter fastMatchFilter, ValueSource valueSource);
コード例 #5
0
ファイル: Range.cs プロジェクト: ChristopherHaws/lucenenet
 /// <summary>
 /// Returns a new <see cref="Filter"/> accepting only documents
 /// in this range.  This filter is not general-purpose;
 /// you should either use it with <see cref="DrillSideways"/> by
 /// adding it to <see cref="DrillDownQuery.Add"/>, or pass it to
 /// <see cref="Search.FilteredQuery"/> using its 
 /// <see cref="Search.FilteredQuery.QUERY_FIRST_FILTER_STRATEGY"/>.
 /// If the <see cref="ValueSource"/> is static, e.g. an indexed numeric
 /// field, then it may be more efficient to use 
 /// <see cref="Search.NumericRangeFilter"/>.  The provided <paramref name="fastMatchFilter"/>,
 /// if non-null, will first be consulted, and only if
 /// that is set for each document will the range then be
 /// checked. 
 /// </summary>
 public abstract Filter GetFilter(Filter fastMatchFilter, ValueSource valueSource);
コード例 #6
0
 /// <summary>
 /// Create {@code RangeFacetCounts}, using the provided
 ///  <seealso cref="ValueSource"/>, and using the provided Filter as
 ///  a fastmatch: only documents passing the filter are
 ///  checked for the matching ranges.  The filter must be
 ///  random access (implement <seealso cref="DocIdSet#bits"/>). 
 /// </summary>
 public DoubleRangeFacetCounts(string field, ValueSource valueSource, FacetsCollector hits, Filter fastMatchFilter, DoubleRange[] ranges)
     : base(field, ranges, fastMatchFilter)
 {
     Count(valueSource, hits.GetMatchingDocs);
 }
コード例 #7
0
 /// <summary>
 /// Create {@code RangeFacetCounts}, using the provided
 ///  <seealso cref="ValueSource"/>. 
 /// </summary>
 public DoubleRangeFacetCounts(string field, ValueSource valueSource, FacetsCollector hits, params DoubleRange[] ranges)
     : this(field, valueSource, hits, null, ranges)
 {
 }
コード例 #8
0
        private void Count(ValueSource valueSource, IEnumerable<MatchingDocs> matchingDocs)
        {
            DoubleRange[] ranges = (DoubleRange[])this.Ranges;

            LongRange[] longRanges = new LongRange[ranges.Length];
            for (int i = 0; i < ranges.Length; i++)
            {
                DoubleRange range = ranges[i];
                longRanges[i] = new LongRange(range.Label, NumericUtils.DoubleToSortableLong(range.minIncl), true, NumericUtils.DoubleToSortableLong(range.maxIncl), true);
            }

            LongRangeCounter counter = new LongRangeCounter(longRanges);

            int missingCount = 0;
            foreach (MatchingDocs hits in matchingDocs)
            {
                FunctionValues fv = valueSource.GetValues(new Dictionary<string,object>(), hits.context);

                TotCount += hits.totalHits;
                Bits bits;
                if (FastMatchFilter != null)
                {
                    DocIdSet dis = FastMatchFilter.GetDocIdSet(hits.context, null);
                    if (dis == null)
                    {
                        // No documents match
                        continue;
                    }
                    bits = dis.GetBits();
                    if (bits == null)
                    {
                        throw new System.ArgumentException("fastMatchFilter does not implement DocIdSet.bits");
                    }
                }
                else
                {
                    bits = null;
                }

                DocIdSetIterator docs = hits.bits.GetIterator();

                int doc;
                while ((doc = docs.NextDoc()) != DocIdSetIterator.NO_MORE_DOCS)
                {
                    if (bits != null && bits.Get(doc) == false)
                    {
                        doc++;
                        continue;
                    }
                    // Skip missing docs:
                    if (fv.Exists(doc))
                    {
                        counter.add(NumericUtils.DoubleToSortableLong(fv.DoubleVal(doc)));
                    }
                    else
                    {
                        missingCount++;
                    }
                }
            }

            missingCount += counter.fillCounts(Counts);
            TotCount -= missingCount;
        }
コード例 #9
0
        private void Count(ValueSource valueSource, IList<MatchingDocs> matchingDocs)
        {
            LongRange[] ranges = (LongRange[])this.Ranges;

            LongRangeCounter counter = new LongRangeCounter(ranges);

            int missingCount = 0;
            foreach (MatchingDocs hits in matchingDocs)
            {
                FunctionValues fv = valueSource.GetValues(new Dictionary<string, object>(), hits.context);

                TotCount += hits.totalHits;
                Bits bits;
                if (FastMatchFilter != null)
                {
                    DocIdSet dis = FastMatchFilter.GetDocIdSet(hits.context, null);
                    if (dis == null)
                    {
                        // No documents match
                        continue;
                    }
                    bits = dis.GetBits();
                    if (bits == null)
                    {
                        throw new System.ArgumentException("fastMatchFilter does not implement DocIdSet.bits");
                    }
                }
                else
                {
                    bits = null;
                }

                DocIdSetIterator docs = hits.bits.GetIterator();
                int doc;
                while ((doc = docs.NextDoc()) != DocIdSetIterator.NO_MORE_DOCS)
                {
                    if (bits != null && bits.Get(doc) == false)
                    {
                        doc++;
                        continue;
                    }
                    // Skip missing docs:
                    if (fv.Exists(doc))
                    {
                        counter.add(fv.LongVal(doc));
                    }
                    else
                    {
                        missingCount++;
                    }
                }
            }

            int x = counter.fillCounts(Counts);

            missingCount += x;

            //System.out.println("totCount " + totCount + " missingCount " + counter.missingCount);
            TotCount -= missingCount;
        }