lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Incze Lajos <in...@mail.matav.hu>
Subject Re: Query syntax on Keyword field question
Date Wed, 24 Mar 2004 20:58:06 GMT
On Tue, Mar 23, 2004 at 08:48:11PM -0600, Chad Small wrote:
> Thanks-you Erik and Incze.  I now understand the issue
> and I'm trying to create a "KeywordAnalyzer" as suggested
> from you book excerpt, Erik:
>  
> http://issues.apache.org/eyebrowse/ReadMsg?listName=lucene-user@jakarta.apache.org&msgNo=6727
>  
> However, not being all that familiar with the Analyzer framework,
> I'm not sure how to implement the "KeywordAnalyzer" even though
> it might be "trivial" :)  Any hints, code, or messages to look at?
>  

Actually, what I've written was not an analyzer, but a NotTokenizingTokenizer,
as I have a very specia analyzer (different needs for different
field catgories) and this is used in that (the code is far from the
phase of any kind of optimization, but you can see the logic):

---
package hu.emnl.lucene.analyzer;

import java.io.IOException;
import java.io.Reader;

import org.apache.lucene.analysis.Token;
import org.apache.lucene.analysis.Tokenizer;

public class NotTokenizingTokenizer extends Tokenizer {

	public NotTokenizingTokenizer() {
		super();
	}

	public NotTokenizingTokenizer(Reader input) {
		super(input);
	}

	public Token next() throws IOException {
		Token t = null;
		int c = input.read();
		if (c >= 0) {
			StringBuffer sb = new StringBuffer();  
			do {
				sb.append((char) c);
				c = input.read();
			} while (c >= 0);
			t = new Token(new String(sb), 0, sb.length());
		}
		return t;
	}
}
---

incze

---------------------------------------------------------------------
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