lucene-pylucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andi Vajda <va...@apache.org>
Subject Re: Problems passing PyLucene objects to jcc-wrapped bobo-browse api
Date Thu, 13 May 2010 05:51:52 GMT

On Wed, 12 May 2010, Julian Maibaum wrote:

> Christian Heimes, Dirk Rothe, and I have jcc-wrapped bobo-browse 
> (http://code.google.com/p/bobo-browse/) in order to add faceted search 
> capabilities to PyLucene. However, the two modules don't play well together, 
> as wrappers from PyLucene cannot be used in a bobo-browse context and vice 
> versa.
> What is the best way to get classes from two different jcc python extension 
> modules to interact?

I've noticed that when there is overlap in Java classes between two 
JCC-built extensions, these kinds of errors occur. One can imagine that if 
the classes have the same name but are not from the same codebase that funny 
version conflicts might arise, for example.

But I haven't looked into exactly what the problem is but a simple 
workaround is to just create one extension that combines both Lucene and 
Bobo-browse. Take the JCC invocation for PyLucene from its Makefile and add 
the things would want from Bobo-browse you want from it and you should have 
something that works better.

Andi..

>
> Setup:
> X64 Ubuntu 9.10 Python 2.6 Tried both versions:
>  JCC-2.4.1-py2.6-linux-x86_64.egg compiled with --shared
>  JCC-2.5.1-py2.6-linux-x86_64.egg compiled with --shared
> Tried both versions:
>  lucene-2.9.1-py2.6-linux-x86_64.egg
>  lucene-2.9.2-py2.6-linux-x86_64.egg
> bobobrowse-2.5.0_rc1-py2.6-linux-x86_64.egg
> Both the bobo-browse python extension module and PyLucene are attached to the 
> main python thread and have been initialized using their respective initVM 
> methods.
>
> I have attached the makefile (modified from PyLucene) that was used to build 
> bobo-browse.
>
> #---- START CODE ----
> import bobobrowse as bb
> import lucene
> import os
>
> CLASSPATH = os.pathsep.join((lucene.CLASSPATH, bb.CLASSPATH)
> lucene.initVM(CLASSPATH)
> bb.initVM(CLASSPATH)
>
> typeHandler = bb.MultiValueFacetHandler("type")
> placeHandler = bb.MultiValueFacetHandler("id")
>
> facetHandlers = lucene.JArray('object')(2, bb.FacetHandler)
> facetHandlers[0] = typeHandler
> facetHandlers[1] = placeHandler
>
> reader = bb.IndexReader.open('/path/to/my/lucene/index', True)
> facetHandlers = bb.Arrays.asList(facetHandlers)
> indexReader = bb.BoboIndexReader.getInstance(reader, facetHandlers)
>
> #---- END CODE ----
>
> Expected:
> The example code above works - java objects from classes wrapped as part of 
> the PyLucene module can transparently be used by other python extension 
> modules such as bobo-browse.
>
> Experienced:
>  Throws Errors:
> Traceback (most recent call last):
> File "./dynamic/vls/search/facets.py", line 115, in <module>
>   test()
> File "./dynamic/smc/jcc/__init__.py", line 52, in wrapper
>   return func(*args, **kwargs)
> File "./dynamic/vls/search/facets.py", line 57, in test
>   facetHandlers = lucene.JArray('object')(2, bb.FacetHandler)
> ValueError: <type 'FacetHandler'>
>
>  and
>
> bobobrowse.InvalidArgsError: (<type 'BoboIndexReader'>, 'getInstance', 
> (<IndexReader: org.apache.lucene.index.DirectoryOwningReader@30419d05>, 
> <List: [com.browseengine.bobo.facets.impl.MultiValueFacetHandler@3f829e6f, 
> com.browseengine.bobo.facets.impl.MultiValueFacetHandler@2980f96c]>))
>
>  respectively.
>
> The Errors can be avoided by changing the corresponding lines in the example 
> above to:
> facetHandlers = bb.JArray('object')(2, bb.FacetHandler)
> reader = bb.IndexReader.open('/path/to/my/lucene/index', True)
>
> However, this only works because lucene's IndexReader is referenced by 
> bobo-browse and has therefore been wrapped at build-time. At later stages 
> other lucene classes are needed to work with bobobrowse that no wrappers have 
> been built for (e.g. QueryParser). I understand that jcc can be forced to 
> built and include wrappers for e.g. org.apache.lucene.queryParser.QueryParser 
> that are then accessible for use with classes from the bobo-browse module as 
> e.g 'bobobrowse.QueryParser'. The most simple solution is calling jcc with an 
> additional --jar lucene.jar parameter - in effect leading to lucene being 
> installed twice: First self-contained PyLucene module and, second, as part of 
> bobo-browse in the flat bobo-browse module namespace. This is not quite 
> desirable:
> Since
> bb.IndexReader.class_ == lucene.IndexReader.class_
> --> class org.apache.lucene.index.IndexReader, anyways, it would arguably be 
> more intuitive to be able to use the available wrappers in the context of 
> other jcc modules even if they have not specifically been forced into that 
> other module. Is there any way to obtain the desired behavior?
>
>
> Thank you very much and all the best,
>
> Julian Maibaum
>
>
> j.maibaum(at)semantics.de
> s<e>mantics GmbH
> http://www.semantics.de
>

Mime
View raw message