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 java.net
> article.... just pull 
> what you need from there to process a TokenStream out
> of an Analyzer.
> 
>       Erik
> 

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
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);
        }

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!
 http://www.compuserve.com/trycsrv/cs2000/webmail/





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to