Reputation: 572
i'm trying to port some Java Lucene code into pylucene (v 2.3.1). i'm using the examples in http://svn.apache.org/viewcvs.cgi/lucene/pylucene/trunk/samples/, and most of pylucene seems to come into my python (ubuntu 12.04, pydev 2.6.0, eclipse 3.7.2) enviroment just fine. eg, i'm able execute lucene.initVM() (showing JCC is in place) and to define a Porter stemmer following the example taken from .../samples/PorterStemmerAnalyzer.py via:
self.analyzer = PorterStemmerAnalyzer()
but when i try to create a new IndexWriter, it stumbles on the last argument to its constructor:
self.writer = lucene.IndexWriter(self.store, self.analyzer, True, lucene.IndexWriter.MaxFieldLength.LIMITED)
i get this error:
AttributeError: type object 'IndexWriter' has no attribute 'MaxFieldLength'.
this is the error that has me stumped at the moment, but there are several other hacks (from their version .../samples) i had also made (but also worry about):
replace lucene.Version.LUCENE_CURRENT with lucene.LucenePackage
lucene.SimpleFSDirectory with lucene.MMapDirectory
in order to get this far.
http://lucene.apache.org/pylucene/features.html says "The PyLucene API exposes all Java Lucene classes in a flat namespace in the PyLucene module." this doesn't seem entirely right, lucene.StopAnalyzer.ENGLISH_STOP_WORDS_SET is known to pydev while lucene.ENGLISH_STOP_WORDS_SET is not.
so it seems i am getting part of/an old version of/...? pylucene engaged correctly, but not all of it!? why might this be?
Upvotes: 1
Views: 997
Reputation: 303
I used rikb's answer and it worked, but I had to change
'linux2': '/usr/lib/jvm/java-7-openjdk-amd64',
to...
'linux2': '/usr/lib/jvm/java-6-openjdk-amd64',
Since I'm using Java 6. It appears he is too, so perhaps he hasn't used that configuration on Linux.
Also note that if you copy and paste all or part rikb's block of stuff for the Makefile you will probably have trailing spaces on each line. Then the 'sudo make' step will fail, rather mysteriously, with a message like "make: execvp: /usr: Permission denied". This is because the trailing space after "PREFIX_PYTHON=/usr " caused make to try to execute the dir /usr.
Upvotes: 0
Reputation: 572
almost certainly the problem had to do with the most recent version of pylucene available as a .deb was 2.3.1 while pylucene is now at v. 3.6.1 !
making from the source distribution takes a bit of touch. the instructions from JohnW at
http://john.wesorick.com/2011/11/installing-pylucene-on-ubuntu-1110.html were helpful.
for what it's worth, here are the changes i wound up making, first to the JDK spec for linux2 in jcc/setup.py
:
JDK = {
'darwin': JAVAHOME,
'ipod': '/usr/include/gcc',
'linux2': '/usr/lib/jvm/java-7-openjdk-amd64',
'sunos5': '/usr/jdk/instances/jdk1.6.0',
'win32': JAVAHOME,
'mingw32': JAVAHOME,
'freebsd7': '/usr/local/diablo-jdk1.6.0'
}
and then to the Makefile:
PREFIX_PYTHON=/usr
ANT=JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 /usr/bin/ant
PYTHON=$(PREFIX_PYTHON)/bin/python
JCC=$(PYTHON) -m jcc --shared
NUM_FILES=4
Upvotes: 1