本文整理汇总了C#中Lucene.Net.Search.TopDocs类的典型用法代码示例。如果您正苦于以下问题:C# TopDocs类的具体用法?C# TopDocs怎么用?C# TopDocs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TopDocs类属于Lucene.Net.Search命名空间,在下文中一共展示了TopDocs类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Medidas
public Medidas(TopDocs hits, Searcher searcher, List<int> docs)
{
this.qtdDocsRelevantesRetornados = DocsRelevantesRecuperados(hits, searcher, docs);
this.precisao = _Precisao(hits.ScoreDocs.Length);
this.cobetura = _Cobertura(docs.Count);
this.fmeasure = _FMeasure();
}
开发者ID:mgtmc,项目名称:MineracaoProj1,代码行数:7,代码来源:Medidas.cs
示例2: 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
示例3: 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
示例4: HitsIncludeTitle
public static bool HitsIncludeTitle(IndexSearcher searcher, TopDocs topDocs, String title)
{
foreach (var scoreDoc in topDocs.ScoreDocs)
{
var doc = searcher.Doc(scoreDoc.Doc);
var docTitle = doc.Get("title");
var decodedTitle = DecodeEncodedNonAsciiCharacters(docTitle);
if (decodedTitle.Equals(title))
{
return true;
}
}
Console.WriteLine("title '" + title + "' not found");
return false;
}
开发者ID:joshball,项目名称:Lucene.In.Action.NET,代码行数:15,代码来源:TestUtils.cs
示例5: 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
示例6: DocsRelevantesRecuperados
private int DocsRelevantesRecuperados(TopDocs hits, Searcher searcher, List<int> docs)
{
int qtd = 0;
foreach (ScoreDoc scoreDoc in hits.ScoreDocs)
{
Document doc = searcher.GetDocument(scoreDoc);
string docId = doc.Get(Constants.FILE_NAME);
string number = docId.Substring(docId.IndexOf('(')+1, docId.IndexOf(')') - docId.IndexOf('(') - 1);
int num = Int32.Parse(number);
if (docs.Contains(num))
qtd++;
}
return qtd;
}
开发者ID:mgtmc,项目名称:MineracaoProj1,代码行数:17,代码来源:Medidas.cs
示例7: WriteV2ResultTest
public void WriteV2ResultTest(
string indexName,
int numDocs,
Dictionary<string, string> commitUserData,
int topDocsTotalHits,
float topDocsMaxScore,
int skip,
int take,
string expected)
{
var searcher = new MockSearcher(indexName, numDocs, commitUserData, versions: Constants.VersionResults);
var topDocs = new TopDocs(topDocsTotalHits, Constants.ScoreDocs, topDocsMaxScore);
var sb = new StringBuilder();
var sw = new StringWriter(sb);
using (var writer = new JsonTextWriter(sw))
{
ResponseFormatter.WriteV2Result(writer, searcher, topDocs, skip, take);
Assert.Equal(expected, sb.ToString());
}
}
开发者ID:NuGet,项目名称:NuGet.Services.Metadata,代码行数:23,代码来源:ResponseFormatterTests.cs
示例8: Search
/// <summary> A search implementation which executes each
/// <see cref="Searchable"/> in its own thread and waits for each search to complete
/// and merge the results back together.
/// </summary>
public override TopDocs Search(Weight weight, Filter filter, int nDocs)
{
HitQueue hq = new HitQueue(nDocs, false);
object lockObj = new object();
TopDocs[] results = new TopDocs[searchables.Length];
//search each searchable
Parallel.For(0, searchables.Length, (i) => results[i] = MultiSearcherCallableNoSort(ThreadLock.MonitorLock, lockObj, searchables[i], weight, filter,
nDocs, hq, i, starts));
int totalHits = 0;
float maxScore = float.NegativeInfinity;
foreach (TopDocs topDocs in results)
{
totalHits += topDocs.TotalHits;
maxScore = Math.Max(maxScore, topDocs.MaxScore);
}
ScoreDoc[] scoreDocs = new ScoreDoc[hq.Size()];
for (int i = hq.Size() - 1; i >= 0; i--) // put docs in array
scoreDocs[i] = hq.Pop();
return new TopDocs(totalHits, scoreDocs, maxScore);
}
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:28,代码来源:ParallelMultiSearcher.cs
示例9: CompareHits
private void CompareHits(IndexReader r, IndexReader joinR, TopDocs results, TopGroups<int> joinResults)
{
// results is 'complete'; joinResults is a subset
int resultUpto = 0;
int joinGroupUpto = 0;
ScoreDoc[] hits = results.ScoreDocs;
IGroupDocs<int>[] groupDocs = joinResults.Groups;
while (joinGroupUpto < groupDocs.Length)
{
IGroupDocs<int> group = groupDocs[joinGroupUpto++];
ScoreDoc[] groupHits = group.ScoreDocs;
assertNotNull(group.GroupValue);
Document parentDoc = joinR.Document(group.GroupValue);
string parentID = parentDoc.Get("parentID");
//System.out.println("GROUP groupDoc=" + group.groupDoc + " parent=" + parentDoc);
assertNotNull(parentID);
assertTrue(groupHits.Length > 0);
for (int hitIDX = 0; hitIDX < groupHits.Length; hitIDX++)
{
Document nonJoinHit = r.Document(hits[resultUpto++].Doc);
Document joinHit = joinR.Document(groupHits[hitIDX].Doc);
assertEquals(parentID, nonJoinHit.Get("parentID"));
assertEquals(joinHit.Get("childID"), nonJoinHit.Get("childID"));
}
if (joinGroupUpto < groupDocs.Length)
{
// Advance non-join hit to the next parentID:
//System.out.println(" next joingroupUpto=" + joinGroupUpto + " gd.Length=" + groupDocs.Length + " parentID=" + parentID);
while (true)
{
assertTrue(resultUpto < hits.Length);
if (!parentID.Equals(r.Document(hits[resultUpto].Doc).Get("parentID")))
{
break;
}
resultUpto++;
}
}
}
}
开发者ID:apache,项目名称:lucenenet,代码行数:43,代码来源:TestBlockJoin.cs
示例10: getResults
private IEnumerable<IAuditEntry> getResults(TopDocs ids, int page, IndexSearcher searcher)
{
int skip = page*20;
return ids.ScoreDocs.Reverse().Skip(skip).Take(20).Select(x => new BasicAuditEntry(searcher.Doc(x.Doc), x.Doc));
}
开发者ID:JeffDarchuk,项目名称:SitecoreSidekick,代码行数:5,代码来源:AuditLogHandler.cs
示例11: TopDocsToMap
// since custom scoring modifies the order of docs, map results
// by doc ids so that we can later compare/verify them
private System.Collections.Hashtable TopDocsToMap(TopDocs td)
{
System.Collections.Hashtable h = new System.Collections.Hashtable();
for (int i = 0; i < td.TotalHits; i++)
{
h[(System.Int32) td.ScoreDocs[i].Doc] = (float) td.ScoreDocs[i].Score;
}
return h;
}
开发者ID:synhershko,项目名称:lucene.net,代码行数:11,代码来源:TestCustomScoreQuery.cs
示例12: CompareChildHits
private void CompareChildHits(IndexReader r, IndexReader joinR, TopDocs results, TopDocs joinResults)
{
assertEquals(results.TotalHits, joinResults.TotalHits);
assertEquals(results.ScoreDocs.Length, joinResults.ScoreDocs.Length);
for (int hitCount = 0; hitCount < results.ScoreDocs.Length; hitCount++)
{
ScoreDoc hit = results.ScoreDocs[hitCount];
ScoreDoc joinHit = joinResults.ScoreDocs[hitCount];
Document doc1 = r.Document(hit.Doc);
Document doc2 = joinR.Document(joinHit.Doc);
assertEquals("hit " + hitCount + " differs", doc1.Get("childID"), doc2.Get("childID"));
// don't compare scores -- they are expected to differ
assertTrue(hit is FieldDoc);
assertTrue(joinHit is FieldDoc);
FieldDoc hit0 = (FieldDoc)hit;
FieldDoc joinHit0 = (FieldDoc)joinHit;
assertArrayEquals(hit0.Fields, joinHit0.Fields);
}
}
开发者ID:apache,项目名称:lucenenet,代码行数:22,代码来源:TestBlockJoin.cs
示例13: AutoCompleteMakeResult
public static JToken AutoCompleteMakeResult(IndexSearcher searcher, TopDocs topDocs, int skip, int take, NuGetSearcherManager searcherManager, bool includeExplanation, Query query)
{
JArray array = new JArray();
for (int i = skip; i < Math.Min(skip + take, topDocs.ScoreDocs.Length); i++)
{
ScoreDoc scoreDoc = topDocs.ScoreDocs[i];
Document document = searcher.Doc(scoreDoc.Doc);
string id = document.Get("Id");
array.Add(id);
}
JObject result = new JObject();
result.Add("@context", new JObject { { "@vocab", "http://schema.nuget.org/schema#" } });
result.Add("totalHits", topDocs.TotalHits);
result.Add("indexName", searcherManager.IndexName);
result.Add("data", array);
if (includeExplanation)
{
JArray explanations = new JArray();
for (int i = skip; i < Math.Min(skip + take, topDocs.ScoreDocs.Length); i++)
{
ScoreDoc scoreDoc = topDocs.ScoreDocs[i];
Explanation explanation = searcher.Explain(query, scoreDoc.Doc);
explanations.Add(explanation.ToString());
}
result.Add("explanations", explanations);
}
return result;
}
开发者ID:jinujoseph,项目名称:NuGet.Services.Metadata,代码行数:34,代码来源:ServiceImpl.cs
示例14: GetTopDocuments
public List<Document> GetTopDocuments(TopDocs topDocs)
{
return topDocs == null ? null : (from ScoreDoc doc in topDocs.ScoreDocs select GetDocument(doc.doc)).ToList();
}
开发者ID:Code-Miners,项目名称:Lucinq,代码行数:4,代码来源:LuceneSearch.cs
示例15: SearchAfter
public override TopDocs SearchAfter(ScoreDoc after, Query query, int numHits)
{
TopDocs[] shardHits = new TopDocs[NodeVersions.Length];
// results are merged in that order: score, shardIndex, doc. therefore we set
// after to after.Score and depending on the nodeID we set doc to either:
// - not collect any more documents with that score (only with worse score)
// - collect more documents with that score (and worse) following the last collected document
// - collect all documents with that score (and worse)
ScoreDoc shardAfter = new ScoreDoc(after.Doc, after.Score);
for (int nodeID = 0; nodeID < NodeVersions.Length; nodeID++)
{
if (nodeID < after.ShardIndex)
{
// all documents with after.Score were already collected, so collect
// only documents with worse scores.
NodeState.ShardIndexSearcher s = OuterInstance.OuterInstance.Nodes[nodeID].Acquire(NodeVersions);
try
{
// Setting after.Doc to reader.MaxDoc-1 is a way to tell
// TopScoreDocCollector that no more docs with that score should
// be collected. note that in practice the shard which sends the
// request to a remote shard won't have reader.MaxDoc at hand, so
// it will send some arbitrary value which will be fixed on the
// other end.
shardAfter.Doc = s.IndexReader.MaxDoc - 1;
}
finally
{
OuterInstance.OuterInstance.Nodes[nodeID].Release(s);
}
}
else if (nodeID == after.ShardIndex)
{
// collect all documents following the last collected doc with
// after.Score + documents with worse scores.
shardAfter.Doc = after.Doc;
}
else
{
// all documents with after.Score (and worse) should be collected
// because they didn't make it to top-N in the previous round.
shardAfter.Doc = -1;
}
if (nodeID == MyNodeID)
{
// My node; run using local shard searcher we
// already aquired:
shardHits[nodeID] = LocalSearchAfter(shardAfter, query, numHits);
}
else
{
shardHits[nodeID] = OuterInstance.OuterInstance.SearchNode(nodeID, NodeVersions, query, null, numHits, shardAfter);
}
//System.out.println(" node=" + nodeID + " totHits=" + shardHits[nodeID].TotalHits);
}
// Merge:
return TopDocs.Merge(null, numHits, shardHits);
}
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:59,代码来源:ShardSearchingTestBase.cs
示例16: RecordResultsAlreadySeenForDistinctQuery
private void RecordResultsAlreadySeenForDistinctQuery(IndexSearcher indexSearcher, TopDocs search, int start, int pageSize)
{
var min = Math.Min(start, search.TotalHits);
// we are paging, we need to check that we don't have duplicates in the previous page
// see here for details: http://groups.google.com/group/ravendb/browse_frm/thread/d71c44aa9e2a7c6e
if (parent.IsMapReduce == false && fieldsToFetch.IsProjection == false && start - pageSize >= 0 && start < search.TotalHits)
{
for (int i = start - pageSize; i < min; i++)
{
var document = indexSearcher.Doc(search.ScoreDocs[i].Doc);
documentsAlreadySeenInPreviousPage.Add(document.Get(Constants.DocumentIdFieldName));
}
}
if (fieldsToFetch.IsDistinctQuery == false)
return;
// add results that were already there in previous pages
for (int i = 0; i < min; i++)
{
Document document = indexSearcher.Doc(search.ScoreDocs[i].Doc);
var indexQueryResult = parent.RetrieveDocument(document, fieldsToFetch, search.ScoreDocs[i]);
alreadyReturned.Add(indexQueryResult.Projection);
}
}
开发者ID:jon-adams,项目名称:ravendb,代码行数:26,代码来源:Index.cs
示例17: TopdocsString
public static string TopdocsString(TopDocs docs, int start, int end)
{
StringBuilder sb = new StringBuilder();
sb.Append("TopDocs totalHits=").Append(docs.TotalHits).Append(" top=").Append(docs.ScoreDocs.Length).Append('\n');
if (end <= 0)
{
end = docs.ScoreDocs.Length;
}
else
{
end = Math.Min(end, docs.ScoreDocs.Length);
}
for (int i = start; i < end; i++)
{
sb.Append('\t');
sb.Append(i);
sb.Append(") doc=");
sb.Append(docs.ScoreDocs[i].Doc);
sb.Append("\tscore=");
sb.Append(docs.ScoreDocs[i].Score);
sb.Append('\n');
}
return sb.ToString();
}
开发者ID:WakeflyCBass,项目名称:lucenenet,代码行数:24,代码来源:CheckHits.cs
示例18: RecordResultsAlreadySeenForDistinctQuery
private void RecordResultsAlreadySeenForDistinctQuery(IndexSearcher indexSearcher, TopDocs search, int start)
{
if (fieldsToFetch.IsDistinctQuery == false)
return;
// add results that were already there in previous pages
var min = Math.Min(start, search.TotalHits);
for (int i = 0; i < min; i++)
{
Document document = indexSearcher.Doc(search.ScoreDocs[i].doc);
var indexQueryResult = parent.RetrieveDocument(document, fieldsToFetch, search.ScoreDocs[i].score);
alreadyReturned.Add(indexQueryResult.Projection);
}
}
开发者ID:richSourceShaper,项目名称:ravendb,代码行数:14,代码来源:Index.cs
示例19: MakeResults
private static string MakeResults(IndexSearcher searcher, TopDocs topDocs, int skip, int take, bool includeExplanation, Query query, long elapsed, IDictionary<string, int> rankings, PackageSearcherManager manager)
{
// note the use of a StringBuilder because we have the response data already formatted as JSON in the fields in the index
StringBuilder strBldr = new StringBuilder();
string timestamp;
if (!searcher.IndexReader.CommitUserData.TryGetValue("commit-time-stamp", out timestamp))
{
timestamp = null;
}
strBldr.AppendFormat("{{\"totalHits\":{0},\"timeTakenInMs\":{1},\"index\":\"{2}\"", topDocs.TotalHits, elapsed, manager.IndexName);
if (!String.IsNullOrEmpty(timestamp))
{
strBldr.AppendFormat(",\"indexTimestamp\":\"{0}\"", timestamp);
}
if (includeExplanation)
{
// JsonConvert.Serialize does escaping and quoting.
strBldr.AppendFormat(",\"executedQuery\":{0}", Newtonsoft.Json.JsonConvert.SerializeObject(query.ToString()));
}
strBldr.Append(",\"data\":[");
bool hasResult = false;
for (int i = skip; i < topDocs.ScoreDocs.Length; i++)
{
ScoreDoc scoreDoc = topDocs.ScoreDocs[i];
Document doc = searcher.Doc(scoreDoc.Doc);
string data = doc.Get("Data");
string id = doc.Get("Id");
NuGet.Versioning.NuGetVersion ngVersion = new Versioning.NuGetVersion(doc.Get("Version"));
if (!String.IsNullOrEmpty(id) && ngVersion != null)
{
Tuple<int,int> countRecord = manager.GetDownloadCount(id,ngVersion.ToNormalizedString());
if (countRecord != null)
{
// Patch the data in to the JSON
JObject parsed = JObject.Parse(data);
parsed["DownloadCount"] = countRecord.Item1;
parsed["PackageRegistration"]["DownloadCount"] = countRecord.Item2;
data = parsed.ToString(Formatting.None);
}
}
if (includeExplanation)
{
data = AddExplanation(searcher, data, query, scoreDoc, rankings);
}
strBldr.Append(data);
strBldr.Append(",");
hasResult = true;
}
if (hasResult)
{
strBldr.Remove(strBldr.Length - 1, 1);
}
strBldr.Append("]}");
string result = strBldr.ToString();
return result;
}
开发者ID:jinujoseph,项目名称:NuGet.Services.Metadata,代码行数:71,代码来源:Searcher.cs
示例20: TopdocsString
public static System.String TopdocsString(TopDocs docs, int start, int end)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("TopDocs totalHits=").Append(docs.totalHits).Append(" top=").Append(docs.scoreDocs.Length).Append('\n');
if (end <= 0)
end = docs.scoreDocs.Length;
else
end = System.Math.Min(end, docs.scoreDocs.Length);
for (int i = start; i < end; i++)
{
sb.Append('\t');
sb.Append(i);
sb.Append(") doc=");
sb.Append(docs.scoreDocs[i].doc);
sb.Append("\tscore=");
sb.Append(docs.scoreDocs[i].score);
sb.Append('\n');
}
return sb.ToString();
}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:20,代码来源:CheckHits.cs
注:本文中的Lucene.Net.Search.TopDocs类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论