所以我试图在 PyLucene 中实现一个基本的索引编写器。我通常是 Java 开发人员,但由于技术限制,我在 python 中执行此操作,否则这不会成为问题。我正在关注 PyLucene Tarball 中的示例,但是
import lucene
from java.io import File
from org.apache.lucene.analysis.standard import StandardAnalyzer
from org.apache.lucene.document import Document, Field
from org.apache.lucene.index import IndexWriter, IndexWriterConfig
from org.apache.lucene.store import SimpleFSDirectory
from org.apache.lucene.util import Version
from org.apache.lucene.store import IOContext
lucene.initVM()
fl = File('index')
indexDir = SimpleFSDirectory(fl)
writerConfig = IndexWriterConfig(Version.LUCENE_6_4_1, StandardAnalyzer())
我遇到的问题是,每当我运行它时,我都会收到以下错误:
Traceback (most recent call last):
File "Indexer.py", line 40, in <module>
indexer = Indexer()
File "Indexer.py", line 22, in __init__
indexDir = SimpleFSDirectory(fl)
lucene.InvalidArgsError: (<type 'SimpleFSDirectory'>, '__init__', (<File: index>,))
我已经检查了这里的 Java 代码,它似乎有一个构造函数public SimpleFSDirectory(File path)
,即使在回溯错误中,这也是我传递的内容。我错过了什么jcc
吗?
这是使用 Lucene 6.4.1,我可以成功导入 lucene 和 jcc。