Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: how to use the Searching by synonyms option
PostPosted: Mon Jan 02, 2012 5:42 am 
Newbie

Joined: Mon Sep 19, 2011 5:05 am
Posts: 14
hello everyone
I would like to know how to add search by synonym. In fact I use my definition of analyzers in a class instead of annotatins when instantiating and I had a problem with SynonymFilter(streams.result, SynonymMap), what is the SynonymMap :
Code:
@Override
    public TokenStream reusableTokenStream(String fieldName, Reader reader) throws IOException {
        SavedStreams streams = (SavedStreams) getPreviousTokenStream();
        if (streams == null) {
            streams = new SavedStreams();
            streams.source = new StandardTokenizer(matchVersion, reader);
            streams.result = new StandardFilter(streams.source);
            streams.result = new LowerCaseFilter(streams.result);
            streams.result = new SnowballFilter(streams.result, name);
            streams.result = new SynonymFilter(streams.result, SynonimMap);
            setPreviousTokenStream(streams);
        } else {
            streams.source.reset(reader);
        }
        return streams.result;
    }

thx


Top
 Profile  
 
 Post subject: Re: how to use the Searching by synonyms option
PostPosted: Wed Jan 11, 2012 6:49 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
org.apache.lucene.analysis.synonym.SynonimMap - it is a Lucene internal class holding the synonym data. At some stage you have to create/load this map so that the word synonyms can be inserted into the token stream. There is SynonimMap.Builder which helps you building the map using external sources (files on the file system).

--Hardy


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.