Search in sources :

Example 1 with FloatColumnReference

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

the class FloatColumnReferenceTest method testFieldCacheExpression.

@Test
public void testFieldCacheExpression() throws Exception {
    MappedFieldType fieldType = FloatFieldMapper.Defaults.FIELD_TYPE.clone();
    fieldType.setNames(new MappedFieldType.Names(column));
    FloatColumnReference floatColumn = new FloatColumnReference(column, fieldType);
    floatColumn.startCollect(ctx);
    floatColumn.setNextReader(readerContext);
    IndexSearcher searcher = new IndexSearcher(readerContext.reader());
    TopDocs topDocs = searcher.search(new MatchAllDocsQuery(), 10);
    float f = -0.5f;
    for (ScoreDoc doc : topDocs.scoreDocs) {
        floatColumn.setNextDocId(doc.doc);
        assertThat(floatColumn.value(), is(f));
        f++;
    }
}
Also used : IndexSearcher(org.apache.lucene.search.IndexSearcher) TopDocs(org.apache.lucene.search.TopDocs) MappedFieldType(org.elasticsearch.index.mapper.MappedFieldType) FloatColumnReference(io.crate.operation.reference.doc.lucene.FloatColumnReference) MatchAllDocsQuery(org.apache.lucene.search.MatchAllDocsQuery) ScoreDoc(org.apache.lucene.search.ScoreDoc) Test(org.junit.Test)

Aggregations

FloatColumnReference (io.crate.operation.reference.doc.lucene.FloatColumnReference)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 MappedFieldType (org.elasticsearch.index.mapper.MappedFieldType)1 Test (org.junit.Test)1