0

I created lucene index in gfsh using the following command

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

My serializer is as follows :

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);
  }
} 

My spring boot configuration file is as follows:


@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);
  }
}

I load data to geode using the following code :

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

describe lucene index --name=myLucIndex --region=myRegion then document # 0 but when I create lucene index using the below command

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

then load the data again, run

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

then document # 96.

I use spring data geode 2.1.8.RELEASE, geode-core 1.9.0, lucene-core 8.2.0

What am I missing here ?

  • Did you check the logs on the server side? Since lucene indexes are maintained asynchronously, and errors from your serializer will show up there. – Dan Smith Sep 17 '19 at 20:45
  • Thanks Dan. Your comment helped. I could find NoClassDefFoundError: org/apache/lucene/document/LatLonPoint error in /ServerOne/ServerOne.log – ajay vasudevan Sep 17 '19 at 22:58
  • I upgraded lucene from 6.6.2 to 8.2.0 while loading data to geode with the above lucene index, I see the below error in /myServer/myServer.log Task failed with exception java.lang.AbstractMethodError: org.apache.lucene.store.Directory.getPendingDeletions()Ljava/util/Set; at org.apache.lucene.index.IndexFileDeleter.(IndexFileDeleter.java:212) What am I done wrong here ? – ajay vasudevan Sep 21 '19 at 16:29
  • deploy --dir=data --groups=myGroup didn't help resolve the error either. – ajay vasudevan Sep 21 '19 at 19:36

1 Answers1

0

Apache Geode currently uses Apache Lucene version 6.6.6 and you're using lucene-core 8.2.0, which is not backward compatible with major older versions like 6.X, that's the reason why you're getting these exceptions. Everything should work just fine if you use the Lucene version shipped with Geode.

As a side note, there are current efforts to upgrade the Lucene version used by Geode, you can follow the progress through GEODE-7039.

Hope this helps.

Juan Ramos
  • 1,421
  • 1
  • 8
  • 13