0

我使用以下命令在gfsh中创建了 lucene 索引

create lucene index --name=myLucIndex --region=myRegion --field=title --analyzer=org.apache.lucene.analysis.en.EnglishAnalyzer --serializer=a.b.c.MyLatLongSerializer

我的序列化程序如下:

class MyLatLongSerializer implements LuceneSerializer<Book> {
@Override
  public Collection<Document> toDocuments(LuceneIndex luceneIndex, Book book) {

    logger.debug("inside custom lucene serializer ...");

    // Writes fields of Book into a document
    Document newDocument = new Document();
    newDocument.add(new StoredField("title", book.getTitle()));
    newDocument.add(new LatLonPoint("location", book.getLatitude(), book.getLongitude()));

    return Collections.singleton(newDocument);
  }
} 

我的spring boot配置文件如下:


@Configuration
@ClientCacheApplication
@EnableClusterDefinedRegions(clientRegionShortcut = ClientRegionShortcut.CACHING_PROXY)
@EnableIndexing
public class BookConfiguration {

  @Bean(name = "bookGemfireCache")
  ClientCacheConfigurer bookGemfireCache(
      @Value("${spring.data.geode.locator.host:localhost}") String hostname,
      @Value("${spring.data.geode.locator.port:10334}") int port) {

    // Get clientCache
  }

  @Bean
  Region<Long, Book> bookRegion(ClientCache clientCache) {
    logger.debug("inside regions ...");
    return clientCache.getRegion("myRegion");
  }

  @Bean
  LuceneService ukBikesLuceneService(ClientCache clientCache) {
    return LuceneServiceProvider.get(clientCache);
  }
}

我使用以下代码将数据加载到 geode:

  bookRegion.putAll(Map<bookId, Book>);

describe lucene index --name=myLucIndex --region=myRegion然后记录 # 0但是当我使用以下命令创建 lucene 索引时

create lucene index --name=myLucIndex --region=myRegion --field=title
--analyzer=org.apache.lucene.analysis.en.EnglishAnalyzer

然后再次加载数据,运行

  describe lucene index --name=myLucIndex --region=myRegion 

然后是文件#96

我使用弹簧数据 geode 2.1.8.RELEASE、geode-core 1.9.0、lucene-core 8.2.0

我在这里想念什么?

4

1 回答 1

0

Apache Geode当前使用Apache Lucene版本6.6.6并且您正在使用lucene-core 8.2.0,它与主要的旧版本(如 )不向后兼容6.X,这就是您收到这些异常的原因。如果您使用 Geode 附带的 Lucene 版本,一切都应该可以正常工作。

附带说明一下,目前正在努力升级 Geode 使用的 Lucene 版本,您可以通过GEODE-7039了解进度。

希望这可以帮助。

于 2020-02-05T13:33:43.657 回答