lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sean Dague <>
Subject Sample SynonymAnalyzer vs. Lucene 2.2
Date Fri, 19 Oct 2007 12:42:18 GMT
I've noticed that the sample code to do the SynonymAnalyzer from the
book Lucene in Action doesn't work right on Lucene 2.2.  In my sample
application I am using categorizing food names into food categories
using the Synonym patern.

Using the excerpted:

  private void addAliasesToStack(Token token) throws IOException {
    String[] synonyms = engine.getSynonyms(token.termText());

    if (synonyms == null) return;

    for (int i = 0; i < synonyms.length; i++) {
      Token synToken = new Token(synonyms[i],


Ends up only indexing the synonym, but not the base word itself.  If I
comment out the 'synToken.setPositionIncrement(0)' line, it works, but
now that throws off the token positions.  This probably doesn't matter,
but I'm curious what the new prefered approach is here?

Thanks in advance,


Sean Dague                                       Mid-Hudson Valley
sean at dague dot net                            Linux Users Group                       

There is no silver bullet.  Plus, werewolves make better neighbors
than zombies, and they tend to keep the vampire population down.

View raw message