当前位置: 首页>>代码示例>>C#>>正文


C# Filter.GetDocIdSet方法代码示例

本文整理汇总了C#中Lucene.Net.Search.Filter.GetDocIdSet方法的典型用法代码示例。如果您正苦于以下问题:C# Filter.GetDocIdSet方法的具体用法?C# Filter.GetDocIdSet怎么用?C# Filter.GetDocIdSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Lucene.Net.Search.Filter的用法示例。


在下文中一共展示了Filter.GetDocIdSet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SearchWithFilter

        private void SearchWithFilter(IndexReader reader, Weight weight, Filter filter, Collector collector)
        {
            DocIdSet docIdSet = filter.GetDocIdSet(reader);
            if (docIdSet == null)
                return;
            Scorer scorer = weight.Scorer(reader, true, false);
            if (scorer == null)
                return;
            scorer.DocID();

            DocIdSetIterator docIdSetIterator = docIdSet.Iterator();
            if (docIdSetIterator == null)
                return;
            int target = docIdSetIterator.NextDoc();
            int num = scorer.Advance(target);
            collector.SetScorer(scorer);
            while (true)
            {
                while (num != target)
                {
                    if (num > target)
                        target = docIdSetIterator.Advance(num);
                    else
                        num = scorer.Advance(target);
                }
                if (num != DocIdSetIterator.NO_MORE_DOCS && !((GroupCollector)collector).GroupLimitReached)
                {
                    collector.Collect(num);
                    target = docIdSetIterator.NextDoc();
                    num = scorer.Advance(target);
                }
                else
                    break;
            }
        }
开发者ID:NHSChoices,项目名称:location-service,代码行数:35,代码来源:GroupedIndexSearcher.cs

示例2: TstFilterCard

 private void TstFilterCard(String mes, int expected, Filter filt)
 {
     DocIdSetIterator disi = filt.GetDocIdSet(reader).Iterator();
     int actual = 0;
     while (disi.NextDoc() != DocIdSetIterator.NO_MORE_DOCS)
     {
         actual++;
     }
     Assert.AreEqual(expected, actual, mes);
 }
开发者ID:synhershko,项目名称:lucene.net,代码行数:10,代码来源:BooleanFilterTest.cs

示例3: FindMatchesInQuery

        private List<FacetMatch> FindMatchesInQuery(Facet facet, Filter query, Filter filter, IndexReader indexReader)
        {
            var matches = facet.Values.Select(value =>
            {
                var bitsQuery = new OpenBitSetDISI(query.GetDocIdSet(indexReader).Iterator(), indexReader.MaxDoc());
                bitsQuery.And(value.Item2);

                if (filter != null)
                {
                    //TODO: Remove this hard coded value (1000)
                    var bitsFilter = new OpenBitSetDISI(filter.GetDocIdSet(indexReader).Iterator(), 1000);
                    bitsQuery.And(bitsFilter);
                }

                var count = bitsQuery.Cardinality();

                return new FacetMatch() { Count = count, Value = value.Item1, Id = facet.Id };
            }).ToList();

            return matches;
        }
开发者ID:tucaz,项目名称:LuceneIndexManager,代码行数:21,代码来源:FacetMatcher.cs

示例4: SearchWithFilter

        private void SearchWithFilter(IndexReader reader, Weight weight, Filter filter, Collector collector)
        {
            System.Diagnostics.Debug.Assert(filter != null);

            Scorer scorer = weight.Scorer(reader, true, false);
            if (scorer == null)
            {
                return ;
            }

            int docID = scorer.DocID();
            System.Diagnostics.Debug.Assert(docID == - 1 || docID == DocIdSetIterator.NO_MORE_DOCS);

            // CHECKME: use ConjunctionScorer here?
            DocIdSet filterDocIdSet = filter.GetDocIdSet(reader);
            if (filterDocIdSet == null)
            {
                // this means the filter does not accept any documents.
                return ;
            }

            DocIdSetIterator filterIter = filterDocIdSet.Iterator();
            if (filterIter == null)
            {
                // this means the filter does not accept any documents.
                return ;
            }
            int filterDoc = filterIter.NextDoc();
            int scorerDoc = scorer.Advance(filterDoc);

            collector.SetScorer(scorer);
            while (true)
            {
                if (scorerDoc == filterDoc)
                {
                    // Check if scorer has exhausted, only before collecting.
                    if (scorerDoc == DocIdSetIterator.NO_MORE_DOCS)
                    {
                        break;
                    }
                    collector.Collect(scorerDoc);
                    filterDoc = filterIter.NextDoc();
                    scorerDoc = scorer.Advance(filterDoc);
                }
                else if (scorerDoc > filterDoc)
                {
                    filterDoc = filterIter.Advance(scorerDoc);
                }
                else
                {
                    scorerDoc = scorer.Advance(filterDoc);
                }
            }
        }
开发者ID:sinsay,项目名称:SSE,代码行数:54,代码来源:IndexSearcher.cs

示例5: getDISI

 private DocIdSetIterator getDISI(Filter filter, IndexReader reader)
 {
     DocIdSet docIdSet = filter.GetDocIdSet(reader);
     if (docIdSet == null)
     {
         return DocIdSet.EMPTY_DOCIDSET.Iterator();
     }
     else
     {
         DocIdSetIterator iter = docIdSet.Iterator();
         if (iter == null)
         {
             return DocIdSet.EMPTY_DOCIDSET.Iterator();
         }
         else
         {
             return iter;
         }
     }
 }
开发者ID:herskinduk,项目名称:Usergroup.Sugnl,代码行数:20,代码来源:ChainedFilter.cs

示例6: GetParentDoc

 private Document GetParentDoc(IndexReader reader, Filter parents, int childDocID)
 {
     IList<AtomicReaderContext> leaves = reader.Leaves;
     int subIndex = ReaderUtil.SubIndex(childDocID, leaves);
     AtomicReaderContext leaf = leaves[subIndex];
     FixedBitSet bits = (FixedBitSet)parents.GetDocIdSet(leaf, null);
     return leaf.AtomicReader.Document(bits.NextSetBit(childDocID - leaf.DocBase));
 }
开发者ID:apache,项目名称:lucenenet,代码行数:8,代码来源:TestBlockJoin.cs

示例7: TstFilterCard

        private void TstFilterCard(string mes, int expected, Filter filt)
        {
            DocIdSet docIdSet = filt.GetDocIdSet(reader.AtomicContext, reader.LiveDocs);
            int actual = 0;
            if (docIdSet != null)
            {
                DocIdSetIterator disi = docIdSet.GetIterator();
                while (disi.NextDoc() != DocIdSetIterator.NO_MORE_DOCS)
                {
                    actual++;
                }
            }

            assertEquals(mes, expected, actual);
        }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:15,代码来源:BooleanFilterTest.cs

示例8: GetDISI

 private DocIdSetIterator GetDISI(Filter filter, AtomicReaderContext context)
 {
     // we dont pass acceptDocs, we will filter at the end using an additional filter
     DocIdSet docIdSet = filter.GetDocIdSet(context, null);
     if (docIdSet == null)
     {
         return DocIdSetIterator.Empty();
     }
     else
     {
         DocIdSetIterator iter = docIdSet.GetIterator();
         if (iter == null)
         {
             return DocIdSetIterator.Empty();
         }
         else
         {
             return iter;
         }
     }
 }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:21,代码来源:ChainedFilter.cs

示例9: AssertDocIdSetCacheable

 private static void AssertDocIdSetCacheable(IndexReader reader, Filter filter, bool shouldCacheable)
 {
     Assert.IsTrue(reader.Context is AtomicReaderContext);
     AtomicReaderContext context = (AtomicReaderContext)reader.Context;
     CachingWrapperFilter cacher = new CachingWrapperFilter(filter);
     DocIdSet originalSet = filter.GetDocIdSet(context, ((AtomicReader)context.Reader()).LiveDocs);
     DocIdSet cachedSet = cacher.GetDocIdSet(context, ((AtomicReader)context.Reader()).LiveDocs);
     if (originalSet == null)
     {
         Assert.IsNull(cachedSet);
     }
     if (cachedSet == null)
     {
         Assert.IsTrue(originalSet == null || originalSet.GetIterator() == null);
     }
     else
     {
         Assert.IsTrue(cachedSet.Cacheable);
         Assert.AreEqual(shouldCacheable, originalSet.Cacheable);
         //System.out.println("Original: "+originalSet.getClass().getName()+" -- cached: "+cachedSet.getClass().getName());
         if (originalSet.Cacheable)
         {
             Assert.AreEqual(originalSet.GetType(), cachedSet.GetType(), "Cached DocIdSet must be of same class like uncached, if cacheable");
         }
         else
         {
             Assert.IsTrue(cachedSet is FixedBitSet || cachedSet == null, "Cached DocIdSet must be an FixedBitSet if the original one was not cacheable");
         }
     }
 }
开发者ID:joyanta,项目名称:lucene.net,代码行数:30,代码来源:TestCachingWrapperFilter.cs

示例10: DocumentFilteredAtomicIndexReader

            public DocumentFilteredAtomicIndexReader(AtomicReaderContext context, Filter preserveFilter, bool negateFilter)
                    : base(context.AtomicReader)
            {
                int maxDoc = @in.MaxDoc;
                FixedBitSet bits = new FixedBitSet(maxDoc);
                // ignore livedocs here, as we filter them later:
                DocIdSet docs = preserveFilter.GetDocIdSet(context, null);
                if (docs != null)
                {
                    DocIdSetIterator it = docs.GetIterator();
                    if (it != null)
                    {
                        bits.Or(it);
                    }
                }
                if (negateFilter)
                {
                    bits.Flip(0, maxDoc);
                }

                if (@in.HasDeletions)
                {
                    Bits oldLiveDocs = @in.LiveDocs;
                    Debug.Assert(oldLiveDocs != null);
                    DocIdSetIterator it = bits.GetIterator();
                    for (int i = it.NextDoc(); i < maxDoc; i = it.NextDoc())
                    {
                        if (!oldLiveDocs.Get(i))
                        {
                            // we can safely modify the current bit, as the iterator already stepped over it:
                            bits.Clear(i);
                        }
                    }
                }

                this.liveDocs = bits;
                this.numDocs_Renamed = bits.Cardinality();
            }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:38,代码来源:PKIndexSplitter.cs

示例11: Search

        public override void Search(Weight weight, Filter filter, Collector results)
        {
            IndexReader reader = IndexReader;

            Scorer scorer = weight.Scorer(reader, true, false);

            if (scorer == null)
            {
                return;
            }

            results.SetScorer(scorer);
            results.SetNextReader(reader, 0);

            FacetValidator validator = CreateFacetValidator();
            int target = 0;
            bool more;

            if (filter == null)
            {
                more = scorer.NextDoc()!=DocIdSetIterator.NO_MORE_DOCS;
                while (more)
                {
                    target = scorer.DocID();
                    if (validator.Validate(target))
                    {
                        results.Collect(target);
                        more = scorer.NextDoc()!=DocIdSetIterator.NO_MORE_DOCS;
                    }
                    else
                    {
                        target = validator.NextTarget;
                        more = scorer.Advance(target) != DocIdSetIterator.NO_MORE_DOCS;
                    }
                }
                return;
            }

            DocIdSetIterator filterDocIdIterator = filter.GetDocIdSet(reader).Iterator(); // CHECKME: use ConjunctionScorer here?

            target = filterDocIdIterator.NextDoc();
            if (target == DocIdSetIterator.NO_MORE_DOCS)
            {
                return;
            }

            int doc = -1;
            while (true)
            {
                if (doc < target)
                {
                    doc = scorer.Advance(target);
                    if (doc == DocIdSetIterator.NO_MORE_DOCS)
                    {
                        break;
                    }
                }

                if (doc == target) // permitted by filter
                {
                    if (validator.Validate(doc))
                    {
                        results.Collect(doc);

                        target = filterDocIdIterator.NextDoc();
                        if (target == DocIdSetIterator.NO_MORE_DOCS)
                        {
                            break;
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else
                    {
                        // skip to the next possible docid
                        target = validator.NextTarget;
                    }
                }
                else // doc > target
                {
                    target = doc;
                }

                target = filterDocIdIterator.Advance(target);
                if (target == DocIdSetIterator.NO_MORE_DOCS)
                {
                    break;
                }
            }
        }
开发者ID:NightOwl888,项目名称:Bobo-Browse.Net,代码行数:92,代码来源:BoboSearcher2.cs

示例12: assertDocIdSetCacheable

 private static void assertDocIdSetCacheable(IndexReader reader, Filter filter, bool shouldCacheable)
 {
     CachingWrapperFilter cacher = new CachingWrapperFilter(filter);
     DocIdSet originalSet = filter.GetDocIdSet(reader);
     DocIdSet cachedSet = cacher.GetDocIdSet(reader);
     Assert.IsTrue(cachedSet.IsCacheable());
     Assert.AreEqual(shouldCacheable, originalSet.IsCacheable());
     //System.out.println("Original: "+originalSet.getClass().getName()+" -- cached: "+cachedSet.getClass().getName());
     if (originalSet.IsCacheable())
     {
         Assert.AreEqual(originalSet.GetType(), cachedSet.GetType(), "Cached DocIdSet must be of same class like uncached, if cacheable");
     }
     else
     {
         Assert.IsTrue(cachedSet is OpenBitSetDISI, "Cached DocIdSet must be an OpenBitSet if the original one was not cacheable");
     }
 }
开发者ID:kstenson,项目名称:NHibernate.Search,代码行数:17,代码来源:TestCachingWrapperFilter.cs

示例13: Search

        // inherit javadoc
        public override void Search(Weight weight, Filter filter, HitCollector results)
        {
            Scorer scorer = weight.Scorer(reader);
            if (scorer == null)
                return;

            if (filter == null)
            {
                scorer.Score(results);
                return;
            }

            DocIdSetIterator filterDocIdIterator = filter.GetDocIdSet(reader).Iterator(); // CHECKME: use ConjunctionScorer here?

            bool more = filterDocIdIterator.Next() && scorer.SkipTo(filterDocIdIterator.Doc());

            while (more)
            {
                int filterDocId = filterDocIdIterator.Doc();
                if (filterDocId > scorer.Doc() && !scorer.SkipTo(filterDocId))
                {
                    more = false;
                }
                else
                {
                    int scorerDocId = scorer.Doc();
                    if (scorerDocId == filterDocId) // permitted by filter
                    {
                        results.Collect(scorerDocId, scorer.Score());
                        more = filterDocIdIterator.Next();
                    }
                    else
                    {
                        more = filterDocIdIterator.SkipTo(scorerDocId);
                    }
                }
            }
        }
开发者ID:cqm0609,项目名称:lucene-file-finder,代码行数:39,代码来源:IndexSearcher.cs

示例14: GetBitSetFromFilter

        public OpenBitSetDISI GetBitSetFromFilter(Filter filter, IndexReader indexReader)
        {
            var bitSet = new OpenBitSetDISI(filter.GetDocIdSet(indexReader).Iterator(), indexReader.MaxDoc());

            return bitSet;
        }
开发者ID:tucaz,项目名称:LuceneIndexManager,代码行数:6,代码来源:Facet.cs

示例15: Search

        public override void Search(Weight weight, Filter filter, Collector results)
        {
            IndexReader reader = IndexReader;

            bool doValidate = false;
            FacetHitCollector[] facetCollectors = this.facetCollectors.ToArray();
            foreach (FacetHitCollector facetCollector in facetCollectors)
            {
                if (facetCollector.PostDocIDSetIterator != null)
                {
                    doValidate = true;
                    break;
                }
            }

            Scorer scorer = weight.Scorer(reader, true, false);
            if (scorer == null)
            {
                return;
            }

            results.SetScorer(scorer);

            if (filter == null)
            {
                while (scorer.NextDoc()!=DocIdSetIterator.NO_MORE_DOCS)
                {
                    int doc = scorer.DocID();
                    if (validateAndIncrement(doc, facetCollectors, doValidate))
                    {
                        results.Collect(doc);
                    }
                }
                return;
            }

            DocIdSetIterator filterDocIdIterator = filter.GetDocIdSet(reader).Iterator(); // CHECKME: use ConjunctionScorer here?

            bool more = filterDocIdIterator.NextDoc() != DocIdSetIterator.NO_MORE_DOCS && scorer.Advance(filterDocIdIterator.DocID()) != DocIdSetIterator.NO_MORE_DOCS;

            while (more)
            {
                int filterDocId = filterDocIdIterator.DocID();
                if (filterDocId > scorer.DocID() && scorer.Advance(filterDocId)==DocIdSetIterator.NO_MORE_DOCS)
                {
                    more = false;
                }
                else
                {
                    int scorerDocId = scorer.DocID();
                    if (scorerDocId == filterDocId) // permitted by filter
                    {
                        if (validateAndIncrement(scorerDocId, facetCollectors, doValidate))
                        {
                            results.Collect(scorerDocId);
                        }
                        more = filterDocIdIterator.NextDoc()!=DocIdSetIterator.NO_MORE_DOCS;
                    }
                    else
                    {
                        more = filterDocIdIterator.Advance(scorerDocId) != DocIdSetIterator.NO_MORE_DOCS;
                    }
                }
            }
        }
开发者ID:NightOwl888,项目名称:Bobo-Browse.Net,代码行数:65,代码来源:BoboSearcher.cs


注:本文中的Lucene.Net.Search.Filter.GetDocIdSet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。