在 Apache Geode Region 中创建 Lucene 索引

问题描述

我正在尝试在 Apache Geode Region 上创建 Lucene 索引。

我在 cache.xml 中有所有区域定义。此 cache.xml 由缓存服务器读取并创建区域。

如果我在 cache.xml 中定义如下所示的区域,

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

Region 是使用 Lucene Index 创建的,但它不允许我添加 Region 的其他属性,例如主键索引、Region 压缩器等。

Geode 说我们应该先创建 Lucene 索引,然后再创建区域。我应该如何为如下所示的区域定义 Lucene 索引。

    <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>

此外,我尝试按照本文档 https://github.com/spring-projects/spring-data-gemfire/blob/main/src/main/asciidoc/reference/lucene.adoc#annotation-configuration-support 使用 Java 注释创建区域。

即使这样我得到必须在区域之前创建 Lucene 索引 错误

解决方法

关于用于定义 Lucene 索引和使用 Apache Geode 的 Lucene 支持的 Spring 配置模型...

由于我不熟悉您如何设置和安排应用程序配置,因此您可以查看一些 SDG 集成测试,看看这是否有助于您确定问题。

首先,查看 SDG 测试套件中的 LuceneOperationsIntegrationTests 类。这个测试类展示了如何使用 JavaConfig 配置一个 Spring 应用程序; example

接下来,看看 SDG 测试套件中的 EnableLuceneIndexingConfigurationIntegrationTests。这个测试类展示了如何使用 SDG Annotations 配置您的 Spring 应用程序; example

请记住,1) Apache Geode Regions 上的 Lucene 索引只能在 PARTITION Regions 上创建,以及 2) PARTITION Regions 只能在集群中的对等服务器上创建。也就是说,Lucene 索引不能应用于 ClientCache 应用程序上的客户端区域。

我怀疑您的应用程序配置缺少 Spring 的 @DependsOn 注释,无论是在模板上还是在包含 Lucene 索引的 Region 上。对于example