lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <e...@ehatchersolutions.com>
Subject Re: Phrase Query
Date Wed, 28 Jul 2004 05:59:35 GMT
On Jul 27, 2004, at 11:42 AM, Hetan Shah wrote:
> Works for me.
> Here is what I am striving to achieve.
>
> phraseString = 	request.getParameter("phrase");
> if (phraseString.length() > 0){
> 	phraseQueryString = "\""+phraseString+("\"");
> 	phraseQuery = true;
> 	queryString = phraseQueryString;
> }
>
> if(phraseQuery){
> 	PhraseQuery pQuery = new PhraseQuery();
> 	pQuery.add(new Term("contents", phraseString));
> 	pQuery.setSlop(0);
> 	QueryParser qP = new QueryParser();
> 	query = qP.parse(phraseString);
> }

I don't understand what you're attempting in the above.  You don't make 
a new Term and add it to a PhraseQuery instance with the term having 
quotes around it - it is QueryParser that deals with quoted strings and 
interpreting it into a PhraseQuery.

Are you using pQuery?  Or query?  You've got two Query instances there 
- query is the one you probably want.

	Erik


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


Mime
View raw message