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 ?
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 like6.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.