Search in sources :

Example 1 with MatchAllDocsQuery

use of org.apache.lucene.search.MatchAllDocsQuery in project crate by crate.

the class LuceneBatchIteratorBenchmark method measureConsumeLuceneBatchIterator.

@Benchmark
public void measureConsumeLuceneBatchIterator(Blackhole blackhole) throws Exception {
    LuceneBatchIterator it = new LuceneBatchIterator(indexSearcher, new MatchAllDocsQuery(), null, false, collectorContext, RAM_ACCOUNTING_CONTEXT, columnRefs, columnRefs);
    Input<?> input = it.rowData().get(0);
    while (it.moveNext()) {
        blackhole.consume(input.value());
    }
}
Also used : MatchAllDocsQuery(org.apache.lucene.search.MatchAllDocsQuery)

Example 2 with MatchAllDocsQuery

use of org.apache.lucene.search.MatchAllDocsQuery in project crate by crate.

the class BooleanColumnReferenceTest method testBooleanExpression.

@Test
public void testBooleanExpression() throws Exception {
    BooleanColumnReference booleanColumn = new BooleanColumnReference(column);
    booleanColumn.startCollect(ctx);
    booleanColumn.setNextReader(readerContext);
    IndexSearcher searcher = new IndexSearcher(readerContext.reader());
    TopDocs topDocs = searcher.search(new MatchAllDocsQuery(), 20);
    int i = 0;
    for (ScoreDoc doc : topDocs.scoreDocs) {
        booleanColumn.setNextDocId(doc.doc);
        assertThat(booleanColumn.value(), is(i % 2 == 0));
        i++;
    }
}
Also used : BooleanColumnReference(io.crate.operation.reference.doc.lucene.BooleanColumnReference) 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)

Example 3 with MatchAllDocsQuery

use of org.apache.lucene.search.MatchAllDocsQuery in project crate by crate.

the class ByteColumnReferenceTest method testByteExpression.

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

Example 4 with MatchAllDocsQuery

use of org.apache.lucene.search.MatchAllDocsQuery 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)

Example 5 with MatchAllDocsQuery

use of org.apache.lucene.search.MatchAllDocsQuery in project crate by crate.

the class LuceneBatchIteratorTest method testLuceneBatchIterator.

@Test
public void testLuceneBatchIterator() throws Exception {
    BatchIteratorTester tester = new BatchIteratorTester(() -> {
        return new LuceneBatchIterator(indexSearcher, new MatchAllDocsQuery(), null, false, new CollectorContext(mock(IndexFieldDataService.class), new CollectorFieldsVisitor(0)), new RamAccountingContext("dummy", new NoopCircuitBreaker("dummy")), columnRefs, columnRefs);
    });
    tester.verifyResultAndEdgeCaseBehaviour(expectedResult);
}
Also used : RamAccountingContext(io.crate.breaker.RamAccountingContext) BatchIteratorTester(io.crate.testing.BatchIteratorTester) CollectorContext(io.crate.operation.reference.doc.lucene.CollectorContext) MatchAllDocsQuery(org.apache.lucene.search.MatchAllDocsQuery) NoopCircuitBreaker(org.elasticsearch.common.breaker.NoopCircuitBreaker) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Aggregations

MatchAllDocsQuery (org.apache.lucene.search.MatchAllDocsQuery)282 IndexSearcher (org.apache.lucene.search.IndexSearcher)168 Directory (org.apache.lucene.store.Directory)133 Document (org.apache.lucene.document.Document)122 RandomIndexWriter (org.apache.lucene.index.RandomIndexWriter)122 IndexReader (org.apache.lucene.index.IndexReader)118 TopDocs (org.apache.lucene.search.TopDocs)91 Sort (org.apache.lucene.search.Sort)71 SortField (org.apache.lucene.search.SortField)64 Query (org.apache.lucene.search.Query)52 BooleanQuery (org.apache.lucene.search.BooleanQuery)49 TermQuery (org.apache.lucene.search.TermQuery)48 FacetsCollector (org.apache.lucene.facet.FacetsCollector)40 Facets (org.apache.lucene.facet.Facets)34 Term (org.apache.lucene.index.Term)33 DirectoryReader (org.apache.lucene.index.DirectoryReader)30 ArrayList (java.util.ArrayList)29 MappedFieldType (org.elasticsearch.index.mapper.MappedFieldType)28 SortedNumericDocValuesField (org.apache.lucene.document.SortedNumericDocValuesField)23 FacetResult (org.apache.lucene.facet.FacetResult)22