本文整理汇总了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();
}
示例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);
}
}
示例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;
}
示例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();
}
}
示例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;
}
}
示例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;
}
示例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("");
}
}
示例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);
}