lucene-pylucene-dev mailing list archives

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

Christian Heimes, Dirk Rothe, and I have jcc-wrapped 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
What is the best way to get classes from two different jcc python extension modules to interact?

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:
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)

typeHandler = bb.MultiValueFacetHandler("type")
placeHandler = bb.MultiValueFacetHandler("id")

facetHandlers = lucene.JArray('object')(2, bb.FacetHandler)
facetHandlers[0] = typeHandler
facetHandlers[1] = placeHandler

reader ='/path/to/my/lucene/index', True)
facetHandlers = bb.Arrays.asList(facetHandlers)
indexReader = bb.BoboIndexReader.getInstance(reader, facetHandlers)

#---- END CODE ----

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.

   Throws Errors:
Traceback (most recent call last):
  File "./dynamic/vls/search/", line 115, in <module>
  File "./dynamic/smc/jcc/", line 52, in wrapper
    return func(*args, **kwargs)
  File "./dynamic/vls/search/", line 57, in test
    facetHandlers = lucene.JArray('object')(2, bb.FacetHandler)
ValueError: <type 'FacetHandler'>


bobobrowse.InvalidArgsError: (<type 'BoboIndexReader'>, 'getInstance', (<IndexReader:
org.apache.lucene.index.DirectoryOwningReader@30419d05>, <List: [com.browseengine.bobo.facets.impl.MultiValueFacetHandler@3f829e6f,


The Errors can be avoided by changing the corresponding lines in the example above to:
facetHandlers = bb.JArray('object')(2, bb.FacetHandler)
reader ='/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
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

Thank you very much and all the best,

Julian Maibaum

s<e>mantics GmbH

View raw message