lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <e...@ehatchersolutions.com>
Subject Re: Search Expansion - more
Date Mon, 05 Apr 2004 17:15:01 GMT
On Apr 5, 2004, at 10:50 AM, hgadm@cswebmail.com wrote:
> 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
> StringReader(myquery[j]));
> 		String str = "";
> 		while (true){
> 			Token token = stream.next();
> 			if (token == null) break;
> 			str = str + token.termText() + " ";
> 			}
> 		query.add(new TermQuery(new Term("subject",
> str.trim())), false, false);
> 	}
>

This doesn't make sense to me.  Why are you appending a space and 
making a single TermQuery for each myquery?  (I don't understand why 
you have an array myquery either, but if you can build a standalone 
simple example - please keep it succinct - maybe I'll understand 
better).  I think you want something more like this:

stream = analyzer.tokenStream("contents", new StringReader(myquery[j]));
while (true){
   Token token = stream.next();
   if (token == null) break;
   query.add(new TermQuery(new Term("subject", token.termText())), 
false, false);
}


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-dev-help@jakarta.apache.org


Mime
View raw message