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.





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

Reply via email to