Search in sources :

Example 1 with ShortColumnReference

use of io.crate.operation.reference.doc.lucene.ShortColumnReference in project crate by crate.

the class ShortColumnReferenceTest method testShortExpression.

@Test
public void testShortExpression() throws Exception {
    ShortColumnReference shortColumn = new ShortColumnReference(column);
    shortColumn.startCollect(ctx);
    shortColumn.setNextReader(readerContext);
    IndexSearcher searcher = new IndexSearcher(readerContext.reader());
    TopDocs topDocs = searcher.search(new MatchAllDocsQuery(), 20);
    short i = -10;
    for (ScoreDoc doc : topDocs.scoreDocs) {
        shortColumn.setNextDocId(doc.doc);
        assertThat(shortColumn.value(), is(i));
        i++;
    }
}
Also used : ShortColumnReference(io.crate.operation.reference.doc.lucene.ShortColumnReference) IndexSearcher(org.apache.lucene.search.IndexSearcher) TopDocs(org.apache.lucene.search.TopDocs) MatchAllDocsQuery(org.apache.lucene.search.MatchAllDocsQuery) ScoreDoc(org.apache.lucene.search.ScoreDoc) Test(org.junit.Test)

Aggregations

ShortColumnReference (io.crate.operation.reference.doc.lucene.ShortColumnReference)1 IndexSearcher (org.apache.lucene.search.IndexSearcher)1 MatchAllDocsQuery (org.apache.lucene.search.MatchAllDocsQuery)1 ScoreDoc (org.apache.lucene.search.ScoreDoc)1 TopDocs (org.apache.lucene.search.TopDocs)1 Test (org.junit.Test)1