SimpleFSDirectory在python lucene中不工作

SimpleFSDirectory在python lucene中不工作,python,indexing,lucene,Python,Indexing,Lucene,即使我尝试了directory=SimpleFSDirectory(文件(os.path.abspath(“paths”))之类的其他方法,SimpleFSDirectory仍然存在错误 InvalidArgError:(,“init”,(,)从5.0开始,SimpleFSDirector不再接受文件参数,而是接受一个。您可以使用File.toPath()转换为路径 另外,我建议您使用。open允许lucene尝试为当前环境选择最佳的目录实现,这通常比SimpleFSDirectory性能更好

即使我尝试了directory=SimpleFSDirectory(文件(os.path.abspath(“paths”))之类的其他方法,SimpleFSDirectory仍然存在错误


InvalidArgError:(,“init”,(,)

从5.0开始,SimpleFSDirector不再接受
文件
参数,而是接受一个。您可以使用
File.toPath()
转换为路径

另外,我建议您使用。open允许lucene尝试为当前环境选择最佳的目录实现,这通常比SimpleFSDirectory性能更好

比如说:

import sys, os
import lucene

from java.io import File
from org.apache.lucene.analysis.standard import StandardAnalyzer
from org.apache.lucene.index import DirectoryReader
from org.apache.lucene.queryparser.classic import QueryParser
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


def index(start, no, dom): 
    lucene.initVM()
    # join base dir and index dir
    path = raw_input("Path for index: ")
    index_path = File(path)
    directory = SimpleFSDirectory(index_path) # the index

从5.0开始,SimpleFSDirectory不再接受
文件
参数,而是接受一个。您可以使用
File.toPath()
转换为路径

另外,我建议您使用。open允许lucene尝试为当前环境选择最佳的目录实现,这通常比SimpleFSDirectory性能更好

比如说:

import sys, os
import lucene

from java.io import File
from org.apache.lucene.analysis.standard import StandardAnalyzer
from org.apache.lucene.index import DirectoryReader
from org.apache.lucene.queryparser.classic import QueryParser
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


def index(start, no, dom): 
    lucene.initVM()
    # join base dir and index dir
    path = raw_input("Path for index: ")
    index_path = File(path)
    directory = SimpleFSDirectory(index_path) # the index