lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel.Cl...@sybase.com
Subject Multiple Analyzers
Date Sun, 30 Oct 2005 16:03:30 GMT

I am implementing a search that allows the user to toggle the Soundex and
Stem functionality on and off.  When the Soundex or Sten functions are not
on, the search will use the StandardAnalyzer as default.  I implemented the
Soundex (SoundexAnalyzer from book Lucene In Action) and Stem
(SnowballAnalyzer) analyzer successfully individually.  They only work if I
use the analyzers during both indexing and searching.  The problem I have
is that I seem to have to use one of the three analyzers or nothing.  I
heven't been able to combine them.  The following may help better to
understand what I am trying to achieve.  Any help would be greatly
appreciated.

Indexing
========
Index using recursive TokenStream object.

public TokenStream tokenStream(String fieldName, Reader reader) {
      TokenStream result = new SoundexFilter (
                        new SnowballFilter (
                           new StopFilter (
                                                                       new
LowerCaseFilter (

new StandardFilter (
new StandardTokenizer(reader))),

StandardAnalyzer.STOP_WORDS)));
      return result;
}

Searching
==========
If user selects Soundex function, use SoundexAnalyzer in query.
Else if user selects Stem option, use SnowballAnalyzer in query.
Else use StandardAnalyzer.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Daniel Clark, Senior Consultant
Sybase Federal Professional Services
6550 Rock Spring Drive, Suite 800
Bethesda, MD  20817
Office - (301) 896-1103
Office Fax - (301) 896-1604
Mobile - (703) 403-0340
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message