本文整理汇总了C#中Lucene.Net.Search.Searcher类的典型用法代码示例。如果您正苦于以下问题:C# Searcher类的具体用法?C# Searcher怎么用?C# Searcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Searcher类属于Lucene.Net.Search命名空间,在下文中一共展示了Searcher类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SearchResults
internal SearchResults(Query query, IEnumerable<SortField> sortField, Searcher searcher, int maxResults)
{
LuceneQuery = query;
LuceneSearcher = searcher;
DoSearch(query, sortField, maxResults);
}
示例2: CheckHits_
public static void CheckHits_(Query query, System.String defaultFieldName, Searcher searcher, int[] results, TestCase testCase)
{
Hits hits = searcher.Search(query);
System.Collections.Hashtable correct = new System.Collections.Hashtable();
for (int i = 0; i < results.Length; i++)
{
correct.Add((System.Int32) results[i], null);
}
System.Collections.Hashtable actual = new System.Collections.Hashtable();
for (int i = 0; i < hits.Length(); i++)
{
actual.Add((System.Int32) hits.Id(i), null);
}
//Assert.AreEqual(correct, actual, query.ToString(defaultFieldName));
if (correct.Count != 0)
{
System.Collections.IDictionaryEnumerator iter = correct.GetEnumerator();
bool status = false;
while (iter.MoveNext())
{
status = actual.ContainsKey(iter.Key);
if (status == false)
break;
}
Assert.IsTrue(status, query.ToString(defaultFieldName));
}
}
示例3: Search
public List<HintResult> Search(Predicate query, int count)
{
if (_searcher == null)
{
_searcher = new IndexSearcher(this._directory, true);
}
TopDocs docsFound = _searcher.Search(query.GetQuery(), count);
var list = new List<HintResult>();
foreach (var score in docsFound.ScoreDocs)
{
Document doc = this._searcher.Doc(score.doc);
var result = new HintResult();
foreach (var field in doc.GetFields())
{
//result.FieldsValues.Add(field. .Name(), field.StringValue());
}
list.Add(result);
}
return list;
}
示例4: TermWeight
public TermWeight(TermQuery enclosingInstance, Searcher searcher)
{
InitBlock(enclosingInstance);
this.similarity = Enclosing_Instance.GetSimilarity(searcher);
idfExp = similarity.IdfExplain(Enclosing_Instance.term, searcher);
idf = idfExp.Idf;
}
示例5: LuceneSearchResults
/// <summary>
/// Initializes a new instance of the <see cref="SearchResults" /> class.
/// </summary>
/// <param name="searcher">The searcher.</param>
/// <param name="reader">The reader.</param>
/// <param name="docs">The hits.</param>
/// <param name="criteria">The criteria.</param>
/// <param name="query">The query.</param>
public LuceneSearchResults(Searcher searcher, IndexReader reader, TopDocs docs, ISearchCriteria criteria, Query query)
{
Results = new SearchResults(criteria, null);
CreateDocuments(searcher, docs);
CreateFacets(reader, query);
CreateSuggestions(reader, criteria);
}
示例6: Hits
internal Hits(Searcher s, Query q, Filter f)
{
weight = q.Weight(s);
searcher = s;
filter = f;
GetMoreDocs(50); // retrieve 100 initially
}
示例7: CountDeletions
// count # deletions, return -1 if unknown.
private int CountDeletions(Searcher s)
{
int cnt = - 1;
if (s is IndexSearcher)
{
cnt = s.MaxDoc() - ((IndexSearcher) s).GetIndexReader().NumDocs();
}
return cnt;
}
示例8: SpanWeight
public SpanWeight(SpanQuery query, Searcher searcher)
{
this.similarity = query.GetSimilarity(searcher);
this.query = query;
terms = new Support.Set<Lucene.Net.Index.Term>();
query.ExtractTerms(terms);
idfExp = similarity.idfExplain(terms.ToArray(), searcher);
idf = idfExp.GetIdf();
}
示例9: SpanWeight
public SpanWeight(SpanQuery query, Searcher searcher)
{
this.similarity = query.GetSimilarity(searcher);
this.query = query;
terms = new System.Collections.Hashtable();
query.ExtractTerms(terms);
idfExp = similarity.idfExplain(new System.Collections.ArrayList(terms.Values), searcher);
idf = idfExp.GetIdf();
}
示例10: Hits
public /*internal*/ bool debugCheckedForDeletions = false; // for test purposes.
internal Hits(Searcher s, Query q, Filter f)
{
weight = q.Weight(s);
searcher = s;
filter = f;
nDeletions = CountDeletions(s);
GetMoreDocs(50); // retrieve 100 initially
lengthAtStart = length;
}
示例11: SpanWeight
public SpanWeight(SpanQuery query, Searcher searcher)
{
this.similarity = query.GetSimilarity(searcher);
this.query = query;
terms = new System.Collections.Hashtable();
query.ExtractTerms(terms);
System.Collections.ArrayList tmp = new System.Collections.ArrayList(terms.Values);
idf = this.query.GetSimilarity(searcher).Idf(tmp, searcher);
}
示例12: GetHighlight
public string GetHighlight(string value, string highlightField, Searcher searcher, string luceneRawQuery)
{
var query = GetQueryParser(highlightField).Parse(luceneRawQuery);
var scorer = new QueryScorer(searcher.Rewrite(query));
var highlighter = new Highlighter(HighlightFormatter, scorer);
var tokenStream = HighlightAnalyzer.TokenStream(highlightField, new StringReader(value));
string bestFragments = highlighter.GetBestFragments(tokenStream, value, MaxNumHighlights, Separator);
return bestFragments;
}
示例13: SpanWeight
public SpanWeight(SpanQuery query, Searcher searcher)
{
this.similarity = query.GetSimilarity(searcher);
this.internalQuery = query;
terms = Lucene.Net.Support.Compatibility.SetFactory.CreateHashSet<Term>();
query.ExtractTerms(terms);
idfExp = similarity.IdfExplain(terms, searcher);
idf = idfExp.Idf;
}
示例14: GetResults
private static void GetResults(ref List<Airport> itemsList, TopDocs results, Searcher searcher)
{
foreach (ScoreDoc scoreDoc in results.ScoreDocs)
{
var item = new Airport();
Document doc = searcher.Doc(scoreDoc.Doc);
item.id = doc.Get("Code");
item.label = doc.Get("CityName") + " - " + doc.Get("Name") + " (" +
doc.Get("Code") + ")";
item.value = doc.Get("CityName") + " - " + doc.Get("Name") + " (" +
doc.Get("Code") + ")";
itemsList.Add(item);
}
}
示例15: CreateDocuments
/// <summary>
/// Creates result document collection from Lucene documents.
/// </summary>
/// <param name="searcher">The searcher.</param>
/// <param name="topDocs">The hits.</param>
private void CreateDocuments(Searcher searcher, TopDocs topDocs)
{
// if no documents found return
if (topDocs == null)
return;
var entries = new List<ResultDocument>();
// get total hits
var totalCount = topDocs.TotalHits;
var recordsToRetrieve = Results.SearchCriteria.RecordsToRetrieve;
var startIndex = Results.SearchCriteria.StartingRecord;
if (recordsToRetrieve > totalCount)
recordsToRetrieve = totalCount;
for (var index = startIndex; index < startIndex + recordsToRetrieve; index++)
{
if (index >= totalCount)
break;
var document = searcher.Doc(topDocs.ScoreDocs[index].Doc);
var doc = new ResultDocument();
var documentFields = document.GetFields();
using (var fi = documentFields.GetEnumerator())
{
while (fi.MoveNext())
{
if (fi.Current != null)
{
var field = fi.Current;
doc.Add(new DocumentField(field.Name, field.StringValue));
}
}
}
entries.Add(doc);
}
var searchDocuments = new ResultDocumentSet
{
Name = "Items",
Documents = entries.OfType<IDocument>().ToArray(),
TotalCount = totalCount
};
Results.Documents = new[] { searchDocuments };
}