lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gregor Heinrich" <Gregor.Heinr...@igd.fhg.de>
Subject RE: Different Analyzer for each Field
Date Mon, 28 Jul 2003 17:09:59 GMT

Hi Claude,

one solution is to make the tokenStream method in the Analyzer subclass
listen to the field name. Example:

	public TokenStream tokenStream(String fieldName, Reader reader) {
		TokenStream result = new StandardTokenizer(reader);

		result = new StandardFilter(result);
		result = new LowerCaseFilter(result);
		result = new StopFilter(result, stoptable);
		if (fieldName.startsWith("phonetic_") && phon != null) {
			result = new PhoneticFilter(result, phon);
			return result;
		}
		result = new SnowballFilter(result, "German");
		return result;
	}

(In my index I have phonetically encoded fields that are filtered
differently.)

Ciao, Gregor


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


Mime
View raw message