Search in sources :

Example 6 with SuggestScoreDoc

use of org.apache.lucene.search.suggest.document.TopSuggestDocs.SuggestScoreDoc in project lucene-solr by apache.

the class TestSuggestField method assertSuggestions.

static void assertSuggestions(TopDocs actual, Entry... expected) {
    SuggestScoreDoc[] suggestScoreDocs = (SuggestScoreDoc[]) actual.scoreDocs;
    for (int i = 0; i < Math.min(expected.length, suggestScoreDocs.length); i++) {
        SuggestScoreDoc lookupDoc = suggestScoreDocs[i];
        String msg = "Hit " + i + ": expected: " + toString(expected[i]) + " but actual: " + toString(lookupDoc);
        assertThat(msg, lookupDoc.key.toString(), equalTo(expected[i].output));
        assertThat(msg, lookupDoc.score, equalTo(expected[i].value));
        assertThat(msg, lookupDoc.context, equalTo(expected[i].context));
    }
    assertThat(suggestScoreDocs.length, equalTo(expected.length));
}
Also used : SuggestScoreDoc(org.apache.lucene.search.suggest.document.TopSuggestDocs.SuggestScoreDoc) IntPoint(org.apache.lucene.document.IntPoint)

Aggregations

SuggestScoreDoc (org.apache.lucene.search.suggest.document.TopSuggestDocs.SuggestScoreDoc)6 IntPoint (org.apache.lucene.document.IntPoint)5 Analyzer (org.apache.lucene.analysis.Analyzer)4 MockAnalyzer (org.apache.lucene.analysis.MockAnalyzer)4 Document (org.apache.lucene.document.Document)4 DirectoryReader (org.apache.lucene.index.DirectoryReader)4 RandomIndexWriter (org.apache.lucene.index.RandomIndexWriter)4 Term (org.apache.lucene.index.Term)4 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 StoredField (org.apache.lucene.document.StoredField)1 IndexWriterConfig (org.apache.lucene.index.IndexWriterConfig)1 ScoreDoc (org.apache.lucene.search.ScoreDoc)1