lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alan Burlison <>
Subject Writing Lucene analyzers - in Scala
Date Tue, 17 Sep 2013 14:38:56 GMT
I know this is the Lucene Java forum but it seemed vaguely appropriate. 
I'm using Lucene from Scala and I needed to subclass a couple of the 
analyzers to set the position increment gap. As the standard analysers 
in question were all final classes I couldn't simply subclass them. 
However it's perfectly possible to write Lucene analyzers entirely in 
Scala. For example, here's the standard KeywordAnalyzer written in Scala 
with a position increment gap of 100.

class MultiKeywordAnalyzer extends Analyzer {
   override protected def createComponents(fieldName: String, reader: 
    TokenStreamComponents = {
     new TokenStreamComponents(new KeywordTokenizer(reader))
   override def getPositionIncrementGap(fieldName: String) = 100

Hopefully this might help someone in the future who googles to see if 
it's possible :-)

Alan Burlison

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message