On Wed, 19 Apr 2006, Victor Ng wrote:
Hi all,
I'm having trouble trying to get PyLucene working with a custom class that
is supposed to be extending MultiTermQuery.
There is no out-of-the-box way to extend a Java Lucene class. A number of Java
Lucene classes can be extended in PyLucene but these were setup for that
purpose. More such classes could be setup that way as follows:
1. a Java subclass of the Lucene class with native extension points needs to
be defined: see the classes in java/org/osafoundation/search for examples
2. the c++ methods for these extension points need to be implemented to call
the equivalent python methods on the python instance they wrap: see
cpp/PythonSearch.cpp for examples
3. the API wrappers in lucene.cpp accepting these extension instances have to
be taught to recognize them as such and wrap whem with an instance of the
java subclass you created in step 1. Look at the method wrapping the
SortField constructor in lucene.cpp, j_sortfield_init(). The case 2:
section tries an argument signature of "sP", which means 'string' followed
by a Java instance of a given class *or* a matching python extension.
Yes, this is tricky. The reason this is so is because the PyLucene objects are
not extensions of Lucene objects but wrappers. The java side has no idea of
this and will not invoke a method override on a python wrapper object.
Andi..
_______________________________________________
pylucene-dev mailing list
[email protected]
http://lists.osafoundation.org/mailman/listinfo/pylucene-dev