lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Miles Barr <>
Subject Re: Problem searching Field.Keyword field
Date Wed, 09 Feb 2005 09:40:49 GMT
On Tue, 2005-02-08 at 12:19 -0500, Steven Rowe wrote:
> Why is there no KeywordAnalyzer?  That is, an analyzer which doesn't 
> mess with its input in any way, but just returns it as-is?
> I realize that under most circumstances, it would probably be more code 
> to use it than just constructing a TermQuery, but having it would 
> regularize query handling, and simplify new users' experience.  And for 
> the purposes of the PerFieldAnalyzerWrapper, it could be helpful.

It's fairly straightforward to write one. Here's the one I put together
for PerFieldAnalyzerWrapper situations:

package org.apache.lucene.analysis;


public class VerbatimAnalyzer extends Analyzer {

    public VerbatimAnalyzer() {

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

        return result;

     * This tokenizer assumes that the entire input is just one token.
    public static class VerbatimTokenizer extends CharTokenizer {

        public VerbatimTokenizer(Reader reader) {

        protected boolean isTokenChar(char c) {
            return true;

Miles Barr <>
Runtime Collective Ltd.

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

View raw message