lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Search Expansion - more
Date Mon, 05 Apr 2004 14:50:04 GMT
On Sun, 4 Apr 2004 13:42:45 -0400, Erik Hatcher wrote:
> You could, perhaps, take an easier way out and run
text through an Analyzer as you build up your query,
without using QueryParser.  Look, 
> again, at my AnalysisDemo code in the
> article.... just pull 
> what you need from there to process a TokenStream out
> of an Analyzer.
> 	Erik


I managed to process the tokenStream further but it
does not allow to search for "host defense"
as phrase.

Here is what I've done:
(input to the function is by the string array myquery
which contains e.g. myquery[1]="term1",
myquery[2]="host defense")

	BooleanQuery query = new BooleanQuery();
	//for each term to add:
	for (int j=0; j<myquery.length; j++){
		stream = analyzer.tokenStream("contents", new
		String str = "";
		while (true){
			Token token =;
			if (token == null) break;
			str = str + token.termText() + " ";
		query.add(new TermQuery(new Term("subject",
str.trim())), false, false);

With this code I tried to assemble single tokens like
"host" and "defense" that are probably coming out of
the analyser back to "host defense" - but it doesn't
find me "host defense" ??

Holger :-(

The ALL NEW CS2000 from CompuServe
 Better!  Faster! More Powerful!
 250 FREE hours! Sign-on Now!

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

View raw message