lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug Cutting <>
Subject RE: Boolean Query Parsing with "IN" keyword
Date Tue, 26 Feb 2002 17:38:13 GMT
> From: Otis Gospodnetic []
> But, StandardAnalyzer is no longer final (get the latest 
> build) and you
> can write a class that subclasses it

Right.  To flesh out Otis' example of how to change StandardAnalyzer's stop
list by defining a subclass of it:

  public class MyAnalyzer extends StandardAnalyzer {
    private static final String[] MY_STOP_WORDS = {"a", "b", ... };
    public MyAnalyzer() {

Another way to do this is to use a different analyzer for the "state" field
than for your other fields:

  public class MyAnalyzer2 extends Analyzer {
    private Analyzer stateAnalyzer = new SimpleAnalyzer();
    private Analyzer otherAnalyzer = new StandardAnalyzer();
    public TokenStream tokenStream(String field, Reader reader) {
      if ("state".equals(field))
        return stateAnalyzer.tokenStream(field, reader);
        return otherAnalyzer.tokenStream(field, reader);

This technique is handy for fields that aren't normal text.  For example,
you could use WhitespaceAnalyzer for a case-sensitive field whose values
contain punctuation.


To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message