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


C# IndexSearcher.MaxDoc方法代码示例

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


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

示例1: Search

        public List<LuceneResult> Search(Query query, Sort sort) {
            var searcher = new IndexSearcher(_rd);
            var collector = TopFieldCollector.create(sort ?? new Sort(), searcher.MaxDoc(), false, true, true, sort == null);
            searcher.Search(query, collector);
            var docs = collector.TopDocs();
            var maxscore = docs.GetMaxScore();

            // Note: cheap way to avoid div/zero
            if(maxscore == 0) {
                maxscore = 1;
            }
            return (from hit in docs.scoreDocs
                    let score = hit.score / maxscore
                    where score >= 0.001f
                    select new LuceneResult(searcher.Doc(hit.doc), score)).ToList();
        }
开发者ID:heran,项目名称:DekiWiki,代码行数:16,代码来源:TestIndex.cs

示例2: GetLogIDsFromMain

 void GetLogIDsFromMain(Query qryHeader, DateTime from, DateTime to, IList<LogQueryResultDetail> results)
 {
     var dateFilter = NumericRangeFilter.NewLongRange(FieldKeys.CreatedDT, 8, DateTime.SpecifyKind(from, DateTimeKind.Utc).Ticks, DateTime.SpecifyKind(to, DateTimeKind.Utc).Ticks, true, true);
     var searcher = new IndexSearcher(directory, true);
     if (searcher.MaxDoc() == 0)
     {
         return;
     }
     var topDocs = searcher.Search(qryHeader, dateFilter, searcher.MaxDoc());
     for (int i = 0; i < topDocs.ScoreDocs.Length; i++)
     {
         //var curDoc = searcher.Doc(topDocs.ScoreDocs[i].doc, new MapFieldSelector(new string[] { FieldKeys.LogName, FieldKeys.LogID }));
         var curDoc = searcher.Doc(topDocs.ScoreDocs[i].doc);
         var curResult = new LogQueryResultDetail()
         {
             Database = curDoc.Get(FieldKeys.LogName),
             ID = Convert.ToInt64(curDoc.Get(FieldKeys.LogID), System.Globalization.CultureInfo.InvariantCulture)
         };
         results.Add(curResult);
     }
 }
开发者ID:simonkang,项目名称:NAppProfiler,代码行数:21,代码来源:NAppIndexReader.cs

示例3: SearchLuceneData

        /// <summary>
        /// 搜索LUCENE数据
        /// </summary>
        /// <param name="indexType"></param>
        /// <param name="query"></param>
        /// <param name="sort"></param>
        /// <param name="pagerInfo"></param>
        /// <param name="callback"></param>
        /// <returns></returns>
        public static List<Document> SearchLuceneData(LuceneTextIndexType indexType, Query query, Sort sort, PagerInfo pagerInfo, SearchLuceneDataLoopItemHandler callback)
        {
            List<Document> list = new List<Document>();

            string textIndexDir = Utilities.GetLuceneTextIndexDirectoryPath(indexType, null);
            FSDirectory directory = FSDirectory.Open(new System.IO.DirectoryInfo(textIndexDir), new NoLockFactory());
            IndexReader indexReader = IndexReader.Open(directory, true);
            IndexSearcher indexSearcher = new IndexSearcher(indexReader);

            ScoreDoc[] docs;
            int totalCount;
            int startOffset;
            int endOffset;

            if (sort != null)
            {
                TopFieldDocs resultFieldDocs = indexSearcher.Search(query, null, indexSearcher.MaxDoc(), sort);
                totalCount = resultFieldDocs.totalHits;
                pagerInfo.RecordCount = totalCount;
                startOffset = (pagerInfo.PageIndex - 1) * pagerInfo.PageSize;
                endOffset = pagerInfo.PageIndex * pagerInfo.PageSize;
                if (endOffset >= totalCount)
                {
                    endOffset = totalCount;
                }
                docs = resultFieldDocs.scoreDocs;
            }
            else
            {
                TopDocs resultFieldDocs = indexSearcher.Search(query, null, indexSearcher.MaxDoc());
                totalCount = resultFieldDocs.totalHits;
                pagerInfo.RecordCount = totalCount;
                startOffset = (pagerInfo.PageIndex - 1) * pagerInfo.PageSize;
                endOffset = pagerInfo.PageIndex * pagerInfo.PageSize;
                if (endOffset >= totalCount)
                {
                    endOffset = totalCount;
                }
                docs = resultFieldDocs.scoreDocs;
            }

            if (totalCount > 0)
            {
                for (int i = startOffset; i < endOffset; i++)
                {
                    ScoreDoc hit = docs[i];
                    Document doc = indexSearcher.Doc(hit.doc);

                    list.Add(doc);

                    if (callback != null)
                    {
                        callback(doc);
                    }
                }
            }

            indexSearcher.Close();
            directory.Close();

            return list;
        }
开发者ID:cityjoy,项目名称:TextIndexMaker,代码行数:71,代码来源:LuceneManager.cs

示例4: GetBits

        public ISearchBits GetBits()
        {
            var query = CreateQuery();
            IndexSearcher searcher;

            try {
                searcher = new IndexSearcher(_directory, true);
            }
            catch {
                // index might not exist if it has been rebuilt
                Logger.Information("Attempt to read a none existing index");
                return null;
            }

            try {
                var filter = new QueryWrapperFilter(query);
                var bits = filter.GetDocIdSet(searcher.GetIndexReader());
                var disi = new OpenBitSetDISI(bits.Iterator(), searcher.MaxDoc());
                return new SearchBits(disi);
            }
            finally {
                searcher.Close();
            }
        }
开发者ID:Timbioz,项目名称:SciGitAzure,代码行数:24,代码来源:LuceneSearchBuilder.cs

示例5: ObterQuantidadeItem

 public int ObterQuantidadeItem(string identificadorCampo, string pesquisa)
 {
     using (var pesquisaIndice = new IndexSearcher(diretorio, readOnly: true))
     {
         var termoPesquisa = new Term(identificadorCampo, pesquisa.ToLower());
         var consulta = new TermQuery(termoPesquisa);
         var resultado = pesquisaIndice.Search(consulta, pesquisaIndice.MaxDoc());
         return resultado.ScoreDocs.Length;
     }
 }
开发者ID:diegocaxito,项目名称:LuceneTest,代码行数:10,代码来源:IndexingTeste.cs

示例6: Search

        private void Search()
        {
            IndexSearcher ish = new IndexSearcher("d:\\lucene");

            //sort

            string strSearch = TextBox1.Text;
            Query q = MultiFieldQueryParser.Parse("" + strSearch + "*", new string[] { "content", "title", "content", "nick", "bname" }, anay);
            Hits his = ish.Search(q);
            string s = string.Format("符合条件记录:{0},索引总记录:{1}", his.Length(), "" + ish.MaxDoc());
            for (int i = 0; i < his.Length(); i++)
            {
                Document doc = his.Doc(i);
                string content = doc.GetField("content").StringValue();
                string title = doc.GetField("title").StringValue();
                string nick = doc.GetField("nick").StringValue();
                string bname = doc.GetField("bname").StringValue();
                string bid = doc.GetField("bid").StringValue();
                string aid = doc.GetField("aid").StringValue();
                s += "<br/><div style='width:100%;background:#ccc'><hr>" + (i + 1) + "title:" + aid + "--" + title + "<hr>content:" + content + "<hr>bname:" + bid + bname + "</div>";
            }
            Literal1.Text = s;
        }
开发者ID:popotans,项目名称:hjnlib,代码行数:23,代码来源:CreateIndex.aspx.cs

示例7: AutoCompleteList_Gys

 public ActionResult AutoCompleteList_Gys()
 {
     try
     {
         string serchlist = "";
         //IndexSearcher search = new IndexSearcher(IndexDic("/Lucene.Net/IndexDic/ProductCatalog"), true);
         IndexSearcher search = new IndexSearcher(new Lucene.Net.Store.SimpleFSDirectory(new System.IO.DirectoryInfo(IndexDic("/Lucene.Net/IndexDic/GysCatalog"))), true);
         int count = search.MaxDoc();
         for (int i = 0; i < count; i++)
         {
             serchlist += search.Doc(i).Get("Name").Trim() + " ";
         }
         return Content(serchlist);
     }
     catch
     {
         return Content("");
     }
 }
开发者ID:269378737,项目名称:go81,代码行数:19,代码来源:商品陈列Controller.cs

示例8: checkIndex

        public void checkIndex()
        {
            try
            {
                searcher = new IndexSearcher(this.pathIndex);
                searcher.Close();
            }
            catch (IOException)
            {
                FncRebuildIndex(this.FilePath);
                //status("The index doesn't exist or is damaged. Please rebuild it.", true);
                return;
            }

            string msg = String.Format("Index is ready. It contains {0} documents.", searcher.MaxDoc());
            status(msg);
        }
开发者ID:jiangguang5201314,项目名称:VMukti,代码行数:17,代码来源:Business_FileSearch.cs


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