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.

@throws(classOf[java.io.IOException])
class MultiKeywordAnalyzer extends Analyzer {
override protected def createComponents(fieldName: String, reader: 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: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org

Reply via email to