我试图在 GAE 应用程序中使用 lucene,但是对于 lucene 3.1.0,即使使用 RAMDirectory(应该没问题,我只有大约 300 个文档要索引),我在提交或关闭索引时出错(见下文)。线索?
Caused by: java.lang.NullPointerException
at org.apache.lucene.store.IndexOutput.writeString(IndexOutput.java:103)
at org.apache.lucene.store.IndexOutput.writeStringStringMap(IndexOutput.java:221)
at org.apache.lucene.index.SegmentInfo.write(SegmentInfo.java:619)
at org.apache.lucene.index.SegmentInfos.write(SegmentInfos.java:381)
at org.apache.lucene.index.SegmentInfos.prepareCommit(SegmentInfos.java:851)
at org.apache.lucene.index.IndexWriter.startCommit(IndexWriter.java:4224)
at org.apache.lucene.index.IndexWriter.prepareCommit(IndexWriter.java:3161)
at org.apache.lucene.index.IndexWriter.commitInternal(IndexWriter.java:3232)
at org.apache.lucene.index.IndexWriter.commit(IndexWriter.java:3214)
at org.apache.lucene.index.IndexWriter.commit(IndexWriter.java:3198)
PS:当然可以在我的机器上运行
最佳答案
几个月前,我已经将其用于 App Engine:
http://ikaisays.com/2010/04/24/lucene-in-memory-search-example-now-updated-for-lucene-3-0-1/
部署到 App Engine 时,您是否保留对 RAMDirectory 的全局引用?这会产生问题,因为您没有单个 JVM——您可能有多个 JVM。请求 #1 可能会转到实例 A,它初始化内存中的索引,但请求 #2 可能会转到实例 B(不同的 JVM),该实例 B 仍然具有索引的空引用。这可能是正在发生的事情吗?
关于google-app-engine - 谷歌应用引擎 (GAE) 上的 Lucene,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6157726/