On Jan 4, 2005, at 9:43 PM, Bill Janssen wrote:Let me be a bit more explicit. My method (essentially an after-method, for those Lisp'rs out there) begins thusly:
protected Query getFieldQuery (String field, Analyzer a, String queryText) throws ParseException {
Query x = super.getFieldQuery(field, a, queryText);
... }
If I remove the "Analyzer a" from both the signature and the super call, the super call won't compile because that method isn't in the QueryParser in 1.4.1. But my getFieldQuery() method won't even be called in 1.4.1, because it doesn't exist in that version of the QueryParser.
Will it work if you override this method also?
protected Query getFieldQuery(String field, Analyzer analyzer, String queryText, int slop)
My head is spinning looking at all the various signatures of this method we have and trying to backtrack where things went awry.
I tried out my suggestion (code pasted below) against lucene-1.4-final.jar and lucene-1.4-3.jar (I don't have the 1.4.1 JAR handy) and was successful. If you override both signatures of getFieldQuery it should work fine for you across all 1.4.x versions. Not ideal, but at least a workaround.
Is this workable for you, Bill?
Erik
public class CustomQueryParser extends QueryParser { public CustomQueryParser(String field, Analyzer analyzer) { super(field, analyzer); }
protected Query getFieldQuery(String field, Analyzer analyzer, String queryText, int slop) throws ParseException {
System.out.println("(slop) queryText = " + queryText);
return null;
}
protected Query getFieldQuery (String field,
Analyzer a,
String queryText)
throws ParseException {
System.out.println("(no-slop) queryText = " + queryText);
return null;
}public static void main(String[] args) throws Exception {
CustomQueryParser qp = new CustomQueryParser("f", new WhitespaceAnalyzer());
qp.parse("foo bar");
qp.parse("\"foo bar\"");
}
}
The output was identical with both versions of Lucene: (no-slop) queryText = foo (no-slop) queryText = bar (slop) queryText = foo bar
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
