Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
12-18-2018 06:22 AM
According to the Neo4j 3.5.0 announcement, it should be possible to add custom Lucene analyzer, but I am not able to find more information on this in the documentation or the forum.
The analyzer we need should actually be included in Lucene (the SimpleAnalyzer
- case insensitive without stop words), but it is not listed by call db.index.fulltext.listAvailableAnalyzers
. As I understand it, all we need to do is to register it in the list of available analyzers. Another option would be to override the stopwords for the standard
analyzer
I would be very happy if someone can point me in the correct direction or provide an example!
Best regards,
Øyvind Wergeland
Solved! Go to Solution.
12-19-2018 04:50 AM
Registration of custom analyzers is simple. Just create a java class extending AnalyzerProvider
that provides the internal name and implementation of the custom analyzer.
As an example take a look at https://github.com/neo4j/neo4j/blob/3.5/community/fulltext-index/src/main/java/org/neo4j/kernel/api/...
Note that the @Service.Implementation
annotation might not work without some tweaks to your build system. Instead make sure you have a service loader file in place:
META-INF/services/org.neo4j.graphdb.index.fulltext.AnalyzerProvider
listing your analyzer provider classes and bundle this with your implementation into a jar file.
That jar file needs to be dropped into neo4j's /plugins
folder.
12-19-2018 04:50 AM
Registration of custom analyzers is simple. Just create a java class extending AnalyzerProvider
that provides the internal name and implementation of the custom analyzer.
As an example take a look at https://github.com/neo4j/neo4j/blob/3.5/community/fulltext-index/src/main/java/org/neo4j/kernel/api/...
Note that the @Service.Implementation
annotation might not work without some tweaks to your build system. Instead make sure you have a service loader file in place:
META-INF/services/org.neo4j.graphdb.index.fulltext.AnalyzerProvider
listing your analyzer provider classes and bundle this with your implementation into a jar file.
That jar file needs to be dropped into neo4j's /plugins
folder.
12-19-2018 07:10 AM
That worked like a charm - thank you very much!
I noted that @org.neo4j.helpers.Service.Implementation
is deprecated. We use @com.google.auto.service.AutoService
to create service loader configuration.
02-17-2019 09:04 AM
Stephan, since we're working with 'stock' Lucene, would it be possible to use this convenience class from Apache?
If so, would I need two classes then, or this one class with that also extends AnalyzerProvider?
Yes, I'm learning Java.
02-18-2019 12:36 AM
neo4joe, you can use that analyzer, but you still need to
Both can be accomplished with a single class CustomAnalyzerProvider
that extends AnalyzerProvider
.
All the sessions of the conference are now available online