Search in sources :

Example 1 with LuceneRawIndexFactory

use of org.apache.geode.cache.lucene.internal.LuceneRawIndexFactory in project geode by apache.

the class LuceneIndexCreationIntegrationTest method shouldCreateRawIndexIfSpecifiedItsFactory.

@Test
public void shouldCreateRawIndexIfSpecifiedItsFactory() throws BucketNotFoundException, InterruptedException {
    Map<String, Analyzer> analyzers = new HashMap<>();
    final RecordingAnalyzer field1Analyzer = new RecordingAnalyzer();
    final RecordingAnalyzer field2Analyzer = new RecordingAnalyzer();
    analyzers.put("field1", field1Analyzer);
    analyzers.put("field2", field2Analyzer);
    LuceneServiceImpl.luceneIndexFactory = new LuceneRawIndexFactory();
    try {
        luceneService.createIndexFactory().setFields(analyzers).create(INDEX_NAME, REGION_NAME);
        Region region = createRegion();
        final LuceneIndex index = luceneService.getIndex(INDEX_NAME, REGION_NAME);
        assertThat(index).isInstanceOf(LuceneRawIndex.class);
        region.put("key1", new TestObject());
        verifyIndexFinishFlushing(cache, INDEX_NAME, REGION_NAME);
        assertEquals(analyzers, index.getFieldAnalyzers());
        assertEquals(Arrays.asList("field1"), field1Analyzer.analyzedfields);
        assertEquals(Arrays.asList("field2"), field2Analyzer.analyzedfields);
    } finally {
        LuceneServiceImpl.luceneIndexFactory = new LuceneIndexImplFactory();
    }
}
Also used : HashMap(java.util.HashMap) LocalRegion(org.apache.geode.internal.cache.LocalRegion) Region(org.apache.geode.cache.Region) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) TestObject(org.apache.geode.cache.lucene.test.TestObject) Analyzer(org.apache.lucene.analysis.Analyzer) LuceneRawIndexFactory(org.apache.geode.cache.lucene.internal.LuceneRawIndexFactory) LuceneIndexImplFactory(org.apache.geode.cache.lucene.internal.LuceneIndexImplFactory) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Aggregations

HashMap (java.util.HashMap)1 Region (org.apache.geode.cache.Region)1 LuceneIndexImplFactory (org.apache.geode.cache.lucene.internal.LuceneIndexImplFactory)1 LuceneRawIndexFactory (org.apache.geode.cache.lucene.internal.LuceneRawIndexFactory)1 TestObject (org.apache.geode.cache.lucene.test.TestObject)1 LocalRegion (org.apache.geode.internal.cache.LocalRegion)1 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)1 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)1 Analyzer (org.apache.lucene.analysis.Analyzer)1 Test (org.junit.Test)1