[pylucene-dev] Creating a class that extends MultiTermQuery

Victor Ng crankycoder at gmail.com
Thu Apr 20 12:40:16 PDT 2006


Hi Andi,

Thanks for the tips.  I think I'm close (probably not), but my C++ is
extremely bad and I can't seem to quite figure out how to get all of this to
work properly.

Any chance that we'll see the ability to create extensions to Query?

I think all we need to get MultiTermQuery wrappers working are extension
points at the isMultiTermQuery() and getEnum(IndexReader) methods.

vic

On 4/19/06, Andi Vajda <vajda at osafoundation.org> wrote:
>
>
> 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
> pylucene-dev at osafoundation.org
> http://lists.osafoundation.org/mailman/listinfo/pylucene-dev
>



--
"Never attribute to malice that which can be adequately explained by
stupidity."  - Hanlon's Razor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osafoundation.org/pipermail/pylucene-dev/attachments/20060420/01df3874/attachment.html


More information about the pylucene-dev mailing list