Search in sources :

Example 1 with SequentialStoredFieldsLeafReader

use of org.elasticsearch.common.lucene.index.SequentialStoredFieldsLeafReader in project crate by crate.

the class InternalEngineTests method testProducesStoredFieldsReader.

@Test
public void testProducesStoredFieldsReader() throws Exception {
    // Make sure that the engine produces a SequentialStoredFieldsLeafReader.
    // This is required for optimizations on SourceLookup to work, which is in-turn useful for runtime fields.
    ParsedDocument doc = testParsedDocument("1", null, testDocumentWithTextField("test"), new BytesArray("{}".getBytes(Charset.defaultCharset())), null);
    Engine.Index operation = randomBoolean() ? appendOnlyPrimary(doc, false, 1) : appendOnlyReplica(doc, false, 1, randomIntBetween(0, 5));
    engine.index(operation);
    engine.refresh("test");
    try (Engine.Searcher searcher = engine.acquireSearcher("test")) {
        IndexReader reader = searcher.getIndexReader();
        assertThat(reader.leaves().size(), Matchers.greaterThanOrEqualTo(1));
        for (LeafReaderContext context : reader.leaves()) {
            assertThat(context.reader(), Matchers.instanceOf(SequentialStoredFieldsLeafReader.class));
            SequentialStoredFieldsLeafReader lf = (SequentialStoredFieldsLeafReader) context.reader();
            assertNotNull(lf.getSequentialStoredFieldsReader());
        }
    }
}
Also used : Searcher(org.elasticsearch.index.engine.Engine.Searcher) BytesArray(org.elasticsearch.common.bytes.BytesArray) SequentialStoredFieldsLeafReader(org.elasticsearch.common.lucene.index.SequentialStoredFieldsLeafReader) ParsedDocument(org.elasticsearch.index.mapper.ParsedDocument) IndexReader(org.apache.lucene.index.IndexReader) LeafReaderContext(org.apache.lucene.index.LeafReaderContext) Test(org.junit.Test)

Aggregations

IndexReader (org.apache.lucene.index.IndexReader)1 LeafReaderContext (org.apache.lucene.index.LeafReaderContext)1 BytesArray (org.elasticsearch.common.bytes.BytesArray)1 SequentialStoredFieldsLeafReader (org.elasticsearch.common.lucene.index.SequentialStoredFieldsLeafReader)1 Searcher (org.elasticsearch.index.engine.Engine.Searcher)1 ParsedDocument (org.elasticsearch.index.mapper.ParsedDocument)1 Test (org.junit.Test)1