1

I'm trying to create Lucene Indexes on Apache Geode Region.

I have all the Region definitions in cache.xml. This cache.xml is read by cache server and Regions are created.

If I define a Region something like below in cache.xml,

    <region name="trackRegion" refid="PARTITION_PERSISTENT">
       <lucene:index name="myIndex">
         <lucene:field name="tenant" />
       </lucene:index>
    </region>

Region is created with Lucene Index, but it doesn't allow me to add other properties of Region like, indexing on primary key, Region compressor etc.

Geode says we should create the Lucene Index first then Region should be created. How should I define the Lucene Index for a Region like below.

    <region name="trackRegion" refid="PARTITION_PERSISTENT">
        <region-attributes>
            <compressor>
                <class-name>org.apache.geode.compression.SnappyCompressor</class-name>
            </compressor>
        </region-attributes>
        <index name="trackRegionKeyIndex" from-clause="/trackRegion" expression="key" key-index="true"/>
    </region>

Also, I tried creating the Region with Java annotations following this document, https://github.com/spring-projects/spring-data-gemfire/blob/main/src/main/asciidoc/reference/lucene.adoc#annotation-configuration-support.

Even with this I get The Lucene Index must be created before Region error.

John Blum
  • 7,381
  • 1
  • 20
  • 30
nandeesh
  • 753
  • 7
  • 16

1 Answers1

0

Regarding the Spring configuration model for defining Lucene Indexes and using Apache Geode's Lucene support...

Since I am not familiar with how you setup and arranged your application configuration, then you can have a look at a few SDG Integration Tests to see if this possibly helps you identify your problem.

First, have a look at the LuceneOperationsIntegrationTests class in the SDG test suite. This test class shows how to configure a Spring application using JavaConfig; for example.

Next, have a look at the EnableLuceneIndexingConfigurationIntegrationTests in the SDG test suite. This test class shows how your Spring application would be configured using SDG Annotations; for example.

Keep in mind that 1) Lucene Indexes on Apache Geode Regions can only be created on PARTITION Regions, and 2) PARTITION Regions can only be created on the peer servers in your cluster. That is, Lucene Indexes cannot be applied to client Regions on a ClientCache application.

I suspect your application configuration is missing Spring's @DependsOn annotation, either on the template or on the Region contaning the Lucene Index. For example.

John Blum
  • 7,381
  • 1
  • 20
  • 30
  • Regarding the Spring configuration model, I will push my code to GitHub and share link here. Do you have any lead WRT cache.xml where I need to define Lucene Index and Key index together for a region.? – nandeesh Jun 03 '21 at 18:12