lucene-pylucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Julian Maibaum <j.maib...@semantics.de>
Subject Problems passing PyLucene objects to jcc-wrapped bobo-browse api
Date Wed, 12 May 2010 16:30:39 GMT
Hi,

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?

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