【问题标题】:No lucene documents created when serializer added添加序列化程序时未创建 lucene 文档
【发布时间】:2019-09-16 20:10:08
【问题描述】:

我使用以下命令在 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 然后 document # 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

我使用spring data geode 2.1.8.RELEASE,geode-core 1.9.0,lucene-core 8.2.0

我在这里错过了什么?

【问题讨论】:

  • 你检查服务器端的日志了吗?由于 lucene 索引是异步维护的,序列化程序的错误会显示在那里。
  • 谢谢丹。你的评论有帮助。我可以在 /ServerOne/ServerOne.log 中找到 NoClassDefFoundError: org/apache/lucene/document/LatLonPoint 错误
  • 我将 lucene 从 6.6.2 升级到 8.2.0,同时使用上述 lucene 索引将数据加载到 geode,我在 /myServer/myServer.log 中看到以下错误 任务失败并出现异常 java.lang。 AbstractMethodError: org.apache.lucene.store.Directory.getPendingDeletions()Ljava/util/Set;在 org.apache.lucene.index.IndexFileDeleter.(IndexFileDeleter.java:212) 我在这里做错了什么?
  • deploy --dir=data --groups=myGroup 也没有帮助解决错误。

标签: lucene spring-data-gemfire geode gfsh


【解决方案1】:

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

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

希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 2019-08-12
    • 1970-01-01
    • 2019-09-25
    • 1970-01-01
    • 2012-02-22
    • 1970-01-01
    • 1970-01-01
    • 2021-12-08
    • 1970-01-01
    相关资源
    最近更新 更多