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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]