lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Fereira <ja...@cornell.edu>
Subject Re: QueryParser implicit conjunction
Date Sat, 25 Jun 2005 11:59:46 GMT
At 03:42 PM 6/24/2005 -0400, you wrote:

>On Jun 24, 2005, at 2:54 PM, John Fereira wrote:
>
>>
>>Last month there was a brief thread about changing the implicit
>>conjuction for search terms from an OR to AND with a response that
>>the API provides a setOperator method for doing so.
>>
>>A site I am developing also required that "AND" be the implicit
>>conjuction so I've tried changing that using the
>>QueryParser.setOperator(1) method. I put in some logging to confirm
>>that the implicit operator is changing but the search results still
>>seem to be producing results using ORing the terms.  Here's what
>>the code looks like:
>>
>>QueryParser qp = new QueryParser( queryField, analyzer);
>>logger.info("operator before: "+qp.getOperator());
>>qp.setOperator(1);
>>logger.info("operator after: "+qp.getOperator());
>>query = qp.parse(searchterms, queryField, analyzer);
>>
>>In the log files it shows that the operator is 0 before the
>>setOperator(1) call has been made, and returns a 1 afterwords.
>>However, when the search is performed it still seems to OR the terms.
>>
>>As a workaround, we just changed the default operator setting in
>>QueryParser.java and rebuilt the jar file but I would prefer to use
>>an official release so that we can update without applying our patch.
>
>Aha!  Look at the method signature of your parse() call.  That is the
>culprit.  To call the non-static method so that you use the
>*instance* of QueryParser rather than the default settings, change to
>this:
>
>     query = qp.parse(searchterms);

Thanks, that fixed it.

   Was there someplace that I should have looked to determine that 
qp.parse(String) would call the non-static method but qp.parse(String, 
String, Analyzer) would not?


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


Mime
View raw message