本文整理汇总了C#中Lucene.Net.Search.Searcher类的典型用法代码示例。如果您正苦于以下问题:C# Searcher类的具体用法?C# Searcher怎么用?C# Searcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Searcher类属于Lucene.Net.Search命名空间,在下文中一共展示了Searcher类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SearchResults
internal SearchResults(Query query, IEnumerable<SortField> sortField, Searcher searcher, int maxResults)
{
LuceneQuery = query;
LuceneSearcher = searcher;
DoSearch(query, sortField, maxResults);
}
开发者ID:rhayesbite,项目名称:Examine,代码行数:7,代码来源:SearchResults.cs
示例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));
}
}
开发者ID:emtees,项目名称:old-code,代码行数:30,代码来源:CheckHits.cs
示例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;
}
开发者ID:bemidio,项目名称:CSharpProjects,代码行数:27,代码来源:LuceneBag.cs
示例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;
}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:7,代码来源:TermQuery.cs
示例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);
}
开发者ID:sameerkattel,项目名称:vc-community,代码行数:15,代码来源:LuceneSearchResults.cs
示例6: Hits
internal Hits(Searcher s, Query q, Filter f)
{
weight = q.Weight(s);
searcher = s;
filter = f;
GetMoreDocs(50); // retrieve 100 initially
}
开发者ID:vineelkovvuri,项目名称:ExtendableDesktopSearch,代码行数:7,代码来源:Hits.cs
示例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;
}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:10,代码来源:Hits.cs
示例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();
}
开发者ID:kstenson,项目名称:NHibernate.Search,代码行数:9,代码来源:SpanWeight.cs
示例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();
}
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:9,代码来源:SpanWeight.cs
示例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;
}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:11,代码来源:Hits.cs
示例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);
}
开发者ID:cqm0609,项目名称:lucene-file-finder,代码行数:11,代码来源:SpanWeight.cs
示例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;
}
开发者ID:joosthollander,项目名称:Macaw.Umbraco.Foundation,代码行数:11,代码来源:LuceneHighlightHelper.cs
示例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;
}
开发者ID:Nangal,项目名称:lucene.net,代码行数:11,代码来源:SpanWeight.cs
示例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);
}
}
开发者ID:varunupcurve,项目名称:myrepo,代码行数:15,代码来源:DestinationService.cs
示例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 };
}
开发者ID:sameerkattel,项目名称:vc-community,代码行数:53,代码来源:LuceneSearchResults.cs
示例16: Expand
/// <summary>
/// Perform synonym expansion on a query.
/// </summary>
/// <param name="query">users query that is assumed to not have any "special" query syntax, thus it should be just normal words, so "big dog" makes sense, but a query like "title:foo^1.2" doesn't as this should presumably be passed directly to the default query parser </param>
/// <param name="syns">a opened to the Lucene index you previously created with <see cref="Syns2Index"/>. The searcher is not closed or otherwise altered. </param>
/// <param name="a">optional analyzer used to parse the users query else <see cref="StandardAnalyzer"/> is used </param>
/// <param name="field">optional field name to search in or null if you want the default of "contents" </param>
/// <param name="boost">optional boost applied to synonyms else no boost is applied </param>
/// <returns>the expanded Query </returns>
public static Query Expand(String query,
Searcher syns,
Analyzer a,
String field,
float boost)
{
already = new List<String>(); // avoid dups
var top = new List<String>(); // needs to be separately listed..
if (field == null)
field = "contents";
if (a == null)
a = new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_CURRENT);
// [1] Parse query into separate words so that when we expand we can avoid dups
var ts = a.TokenStream(field, new StringReader(query));
var termAtt = ts.AddAttribute<TermAttribute>();
while (ts.IncrementToken())
{
var word = termAtt.Term;
if (!already.Contains(word))
{
already.Add(word);
top.Add(word);
}
}
tmp = new BooleanQuery();
// [2] form query
System.Collections.IEnumerator it = top.GetEnumerator();
while (it.MoveNext())
{
// [2a] add to level words in
var word = (String) it.Current;
var tq = new TermQuery(new Term(field, word));
tmp.Add(tq, Occur.SHOULD);
var c = new CollectorImpl(field, boost);
syns.Search(new TermQuery(new Term(Syns2Index.F_WORD, word)), c);
}
return tmp;
}
开发者ID:synhershko,项目名称:lucene.net,代码行数:55,代码来源:SynExpand.cs
示例17: SearchService
public SearchService()
{
var tmpluceneIndexDir = LuceneStore.FSDirectory.Open(INDEX_DIR);
luceneIndexDir = new LuceneStore.RAMDirectory(tmpluceneIndexDir);
tmpluceneIndexDir.Close();
analyzer = new StandardAnalyzer(LuceneUtil.Version.LUCENE_29);
reader = IndexReader.Open(luceneIndexDir, true); // only searching, so read-only=true
searcher = new IndexSearcher(reader);
// parser = new QueryParser(LuceneUtil.Version.LUCENE_29, "analized_path", analyzer);
parser = new QueryParser(LuceneUtil.Version.LUCENE_29, "name", analyzer);
parser.SetDefaultOperator(QueryParser.Operator.AND);
parser.SetAllowLeadingWildcard(true);
}
开发者ID:ksopyla,项目名称:winmole,代码行数:19,代码来源:SearchService.cs
示例18: CheckNoMatchExplanations
public static float EXPLAIN_SCORE_TOLERANCE_DELTA = 0.00025f; // {{See: LUCENENET-288}} Intentional diversion from Java Lucene per above comment
/// <summary> Tests that all documents up to maxDoc which are *not* in the
/// expected result set, have an explanation which indicates no match
/// (ie: Explanation value of 0.0f)
/// </summary>
public static void CheckNoMatchExplanations(Query q, System.String defaultFieldName, Searcher searcher, int[] results)
{
System.String d = q.ToString(defaultFieldName);
System.Collections.Hashtable ignore = new System.Collections.Hashtable();
for (int i = 0; i < results.Length; i++)
{
SupportClass.CollectionsHelper.AddIfNotContains(ignore, (System.Int32) results[i]);
}
int maxDoc = searcher.MaxDoc();
for (int doc = 0; doc < maxDoc; doc++)
{
if (ignore.Contains((System.Int32) doc))
continue;
Explanation exp = searcher.Explain(q, doc);
Assert.IsNotNull(exp, "Explanation of [[" + d + "]] for #" + doc + " is null");
Assert.AreEqual(0.0f, exp.GetValue(), 0.0f, "Explanation of [[" + d + "]] for #" + doc + " doesn't indicate non-match: " + exp.ToString());
}
}
开发者ID:Rationalle,项目名称:ravendb,代码行数:27,代码来源:CheckHits.cs
示例19: searchReviewables
public static Hashtable searchReviewables(string searchText)
{
query = parser.Parse(searchText + "*");
Hashtable results = new Hashtable();
lock (my_lock)
{
//Lucene.Net.Search.TopDocs hits = null;
Lucene.Net.Search.TopDocs hits = null;
try
{
if (searcher == null)
{
Lucene.Net.Store.FSDirectory d = Lucene.Net.Store.FSDirectory.Open(_indexPath);
searcher = new Lucene.Net.Search.IndexSearcher(d);
}
hits = searcher.Search(query, 200);
}
catch (Exception e)
{
}
for (int i = 0; i < hits.ScoreDocs.Count() - 1; i++)
{
Document doc = searcher.Doc(hits.ScoreDocs[i].Doc);
string id = doc.GetField("reviewableid").StringValue;
if (!results.Contains(id))
results.Add(id, hits.ScoreDocs[i].Score);
float x = hits.MaxScore;
}
}
return results;
}
开发者ID:cmdprompt1911,项目名称:Dimmi,代码行数:38,代码来源:SearchProcessor.cs
示例20: BooleanWeight
public BooleanWeight(BooleanQuery enclosingInstance, Searcher searcher)
{
InitBlock(enclosingInstance);
this.similarity = Enclosing_Instance.GetSimilarity(searcher);
for (int i = 0; i < Enclosing_Instance.clauses.Count; i++)
{
BooleanClause c = (BooleanClause) Enclosing_Instance.clauses[i];
weights.Add(c.GetQuery().CreateWeight(searcher));
}
}
开发者ID:cqm0609,项目名称:lucene-file-finder,代码行数:10,代码来源:BooleanQuery.cs
注:本文中的Lucene.Net.Search.Searcher类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论