lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mathieu Lecarme <math...@garambrogne.net>
Subject Re: designing a dictionary filter with multiple word entries
Date Wed, 09 Apr 2008 07:42:25 GMT
Allen Atamer a écrit :
> My dictionary filter currently implements next() and everything works well
> when dictionary entries are replaced one-to-one. For example:   Can =>
> Canada. 
>
> A problem arises when I try to replace it with more than one word. Going
> through next() I encounter "shutdown".  But the dictionary entry takes
> Shutdown => shut down (two words). I construct a replacement term according
> the to the instructions in the Javadoc, but the search does not match any
> substrings "shut" or "down" in my database. I debugged it and found
> QueryParser is converting my replaced text into PhraseQuery objects instead
> of BooleanQuery objects.
>
> My code to replace the string is below:
>
> 		Token teachToken = new Token();
> 		teachToken.resizeTermBuffer(replacementTerm.length());
> 		
> 		char [] termBuffer = teachToken.termBuffer();
> 		for (int i = 0; i < replacementTerm.length(); i++) {
> 			termBuffer[i] = replacementTerm.charAt(i);
> 		}
> 		teachToken.setTermLength(replacementTerm.length());
> 		this.tokenQueue.push(teachToken);
> 		return teachToken;
>
> Instead of [field1]:shut down, it is searching with [field1]:"shut down".
>
> How can I construct the replacement terms so that queries are formed
> properly, and I don't violate the next() contract?
>   
use a private stack. When you replace a word, fill it, and the next() 
will pop your stack. When the stack is empty, feed it again. So first 
time next() will get "shut", and second time "down".

M.


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