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

Reply via email to