On Thu, 2 Mar 2006, Bill Janssen wrote:

I've been looking at a conversion of a Java Lucene project to
PyLucene, using PyLucene 1.9 on Python 2.3.5 on a Mac.  So far, so

PyLucene 2.4 is required, your mileage with 2.3 will vary, although 2.3.5 may be close enough.

good, but I don't see how to subclass MultiFieldQueryParser properly.
I have to override both "parseQuery" and "getFieldQuery" (and probably
"getRangeQuery") in my subclass.

Indeed, there is no way to do this at the moment without adding a class analogous to the one added to extend QueryParser called PythonQueryParser.

There is no way to override parseQuery on QueryParser either, by the way.
The QueryParser extension class, PythonQueryParser, only has extensions hooks for the various get<Kind>Query() methods.

If I define a new Python class that inherits from the Python
MultiFieldQueryParser class, my override of "parseQuery" works, but
"getFieldQuery" doesn't.

Extending a python wrapper class will not work because the java side is not aware of it. The python class you're extending is only a wrapper class around the java class it is *declared* to extend. The java side has no idea that the python wrapper has 'extended' some of its methods.

If I use the analyzer.queryParser() trick illustrated in the examples,
"getFieldQuery" gets called, but not "parseQuery".  What's worse,
there's only one default field name with that approach, so it won't
really work.

Indeed, PythonQueryParser, which gets instantiated in that situation, doesn't allow for a parseQuery() override. I could easily fix that but analyzer.queryParser() would still only give you an instance of a subclass of QueryParser, not MultiFieldQueryParser. Would also adding a new method on Analyzer, called multiFieldQueryParser() analogous to queryParser() but returning a MultiFieldQueryParser instance be enough ?

Let me work on an enhancement.....

Andi..
_______________________________________________
pylucene-dev mailing list
[email protected]
http://lists.osafoundation.org/mailman/listinfo/pylucene-dev

Reply via email to