本文整理汇总了C#中Lucene.Net.Search.ScoreDoc类的典型用法代码示例。如果您正苦于以下问题:C# ScoreDoc类的具体用法?C# ScoreDoc怎么用?C# ScoreDoc使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ScoreDoc类属于Lucene.Net.Search命名空间,在下文中一共展示了ScoreDoc类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: constructor_should_convert_document_and_scoredoc_to_properties_and_parse_createdon_date
public void constructor_should_convert_document_and_scoredoc_to_properties_and_parse_createdon_date()
{
// Arrange
LuceneDocument document = new LuceneDocument();
document.Add(CreateField("id","123"));
document.Add(CreateField("title", "the title"));
document.Add(CreateField("contentsummary", "the summary"));
document.Add(CreateField("tags", "tag1 tag2"));
document.Add(CreateField("createdby", "gandhi"));
document.Add(CreateField("contentlength", "999"));
document.Add(CreateField("createdon", DateTime.Today.ToString()));
ScoreDoc scoreDoc = new ScoreDoc(0, 9.50f);
// Act
SearchResultViewModel model = new SearchResultViewModel(document, scoreDoc);
// Assert
Assert.That(model.Id, Is.EqualTo(123));
Assert.That(model.Title, Is.EqualTo("the title"));
Assert.That(model.ContentSummary, Is.EqualTo("the summary"));
Assert.That(model.Tags, Is.EqualTo("tag1 tag2"));
Assert.That(model.CreatedBy, Is.EqualTo("gandhi"));
Assert.That(model.ContentLength, Is.EqualTo(999));
Assert.That(model.CreatedOn, Is.EqualTo(DateTime.Today)); // only the date should be parsed
Assert.That(model.Score, Is.EqualTo(9.50f));
}
示例2: TopScoreDocCollector
// prevents instantiation
private TopScoreDocCollector(int numHits)
: base(new HitQueue(numHits, true))
{
// HitQueue implements getSentinelObject to return a ScoreDoc, so we know
// that at this point top() is already initialized.
pqTop = (ScoreDoc) pq.Top();
}
示例3: Add
/// <summary>
/// Adds an Object to a PriorityQueue in log(size) time. If one tries to add
/// more objects than maxSize from initialize an
/// {@link ArrayIndexOutOfBoundsException} is thrown.
/// </summary>
/// <param name="element"></param>
/// <returns>the new 'bottom' element in the queue.</returns>
public ScoreDoc Add(ScoreDoc element)
{
size++;
heap[size] = element;
UpHeap(size);
return heap[1];
}
示例4: PopulateResults
/// <summary> Populates the results array with the ScoreDoc instaces. This can be
/// overridden in case a different ScoreDoc type should be returned.
/// </summary>
protected internal virtual void PopulateResults(ScoreDoc[] results, int howMany)
{
for (int i = howMany - 1; i >= 0; i--)
{
results[i] = (ScoreDoc) pq.Pop();
}
}
示例5: ConvertToDataTable
private static DataTable ConvertToDataTable(IndexSearcher indexSearcher, ScoreDoc[] result)
{
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn(LuceneConfig.Field_Path));
dt.Columns.Add(new DataColumn(LuceneConfig.Field_FileName));
dt.Columns.Add(new DataColumn(LuceneConfig.Field_PageNumber));
dt.Columns.Add(new DataColumn(LuceneConfig.Field_ContentByPage));
dt.Columns.Add(new DataColumn(LuceneConfig.Field_Score));
foreach (ScoreDoc scoreDoc in result)
{
Document doc = indexSearcher.Doc(scoreDoc.Doc);
DataRow dr = dt.NewRow();
dr[LuceneConfig.Field_Path] = doc.Get(LuceneConfig.Field_Path);
dr[LuceneConfig.Field_FileName] = doc.Get(LuceneConfig.Field_FileName);
dr[LuceneConfig.Field_PageNumber] = doc.Get(LuceneConfig.Field_PageNumber);
dr[LuceneConfig.Field_ContentByPage] = doc.Get(LuceneConfig.Field_ContentByPage);
dr[LuceneConfig.Field_Score] = scoreDoc.Score;
dt.Rows.Add(dr);
}
return dt;
}
示例6: CheckDocIds
/// <summary>
/// Tests that a Hits has an expected order of documents </summary>
public static void CheckDocIds(string mes, int[] results, ScoreDoc[] hits)
{
Assert.AreEqual(hits.Length, results.Length, mes + " nr of hits");
for (int i = 0; i < results.Length; i++)
{
Assert.AreEqual(results[i], hits[i].Doc, mes + " doc nrs for hit " + i);
}
}
示例7: Compare
public virtual int Compare(ScoreDoc i, ScoreDoc j)
{
if (i.score > j.score)
return - 1;
if (i.score < j.score)
return 1;
return 0;
}
示例8: CompareRanks
protected void CompareRanks(ScoreDoc[] hits, int[] ranks)
{
Assert.AreEqual(ranks.Length, hits.Length);
for (int i = 0; i < ranks.Length; i++)
{
Assert.AreEqual(ranks[i], hits[i].Doc);
}
}
示例9: Should_Throw_ArgumentNullException_When_Document_Is_Null
public void Should_Throw_ArgumentNullException_When_Document_Is_Null()
{
// Arrange
LuceneDocument document = null;
ScoreDoc scoreDoc = new ScoreDoc(0, 9.50f);
// Act + Assert
SearchResultViewModel model = new SearchResultViewModel(document, scoreDoc);
}
示例10: Compare
public override int Compare(ScoreDoc doc1, ScoreDoc doc2)
{
for (int i = 0; i < _comparators.Length; ++i)
{
int v = _comparators[i].Compare(doc1, doc2);
if (v != 0) return v;
}
return 0;
}
示例11: PreviousSearchState
public PreviousSearchState(Query query, Sort sort, ScoreDoc searchAfterLocal, ScoreDoc searchAfterShard, long[] versions, int numHitsPaged)
{
this.Versions = (long[])versions.Clone();
this.SearchAfterLocal = searchAfterLocal;
this.SearchAfterShard = searchAfterShard;
this.Sort = sort;
this.Query = query;
this.NumHitsPaged = numHitsPaged;
SearchTimeNanos = TimeHelper.NanoTime();
}
示例12: Compare
public int Compare(ScoreDoc i, ScoreDoc j)
{
int fi = fieldOrder[i.doc];
int fj = fieldOrder[j.doc];
if (fi < fj)
return - 1;
if (fi > fj)
return 1;
return 0;
}
示例13: TopDocs
// javadoc inherited
public override TopDocs TopDocs()
{
FieldSortedHitQueue fshq = (FieldSortedHitQueue) hq;
ScoreDoc[] scoreDocs = new ScoreDoc[fshq.Size()];
for (int i = fshq.Size() - 1; i >= 0; i--)
// put docs in array
scoreDocs[i] = fshq.FillFields((FieldDoc) fshq.Pop());
return new TopFieldDocs(totalHits, scoreDocs, fshq.GetFields(), fshq.GetMaxScore());
}
示例14: TopDocs
/// <summary>The top-scoring hits. </summary>
public virtual TopDocs TopDocs()
{
ScoreDoc[] scoreDocs = new ScoreDoc[hq.Size()];
for (int i = hq.Size() - 1; i >= 0; i--)
// put docs in array
scoreDocs[i] = (ScoreDoc) hq.Pop();
float maxScore = (totalHits == 0) ? System.Single.NegativeInfinity : scoreDocs[0].score;
return new TopDocs(totalHits, scoreDocs, maxScore);
}
示例15: AllHitsCollector
public AllHitsCollector(ScoreDoc[] docs)
{
this.outOfOrder = true;
this.shouldScore = true;
hits = new List<AllHit>(docs.Length);
foreach (var doc in docs)
{
this.hits.Add(new AllHit(doc.doc, doc.score));
}
}