从索引中删除一个文档后,通过 IndexWriter.UpdateDocument 更新同样的文档在 IndexWriter.Commit 提交时报错
System.IO.FileNotFoundException: Could not find file '/zzk/index/blogpost/_bkd.cfs'.
File name: '/zzk/index/blogpost/_bkd.cfs'
at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirError)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, UnixFileMode openPermissions, Int64& fileLength, UnixFileMode& filePermissions, Func`4 createOpenException)
at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
at Lucene.Net.Store.MMapDirectory.OpenInput(String name, IOContext context)
at Lucene.Net.Store.MMapDirectory.CreateSlicer(String name, IOContext context)
at Lucene.Net.Store.CompoundFileDirectory..ctor(Directory directory, String fileName, IOContext context, Boolean openForWrite)
at Lucene.Net.Index.SegmentReader.ReadFieldInfos(SegmentCommitInfo info)
at Lucene.Net.Index.SegmentReader..ctor(SegmentCommitInfo si, Int32 termInfosIndexDivisor, IOContext context)
at Lucene.Net.Index.ReadersAndUpdates.GetReader(IOContext context)
at Lucene.Net.Index.BufferedUpdatesStream.ApplyDeletesAndUpdates(ReaderPool readerPool, IList`1 infos)
at Lucene.Net.Index.IndexWriter.ApplyAllDeletesAndUpdates()
at Lucene.Net.Index.IndexWriter.MaybeApplyDeletes(Boolean applyAllDeletes)
at Lucene.Net.Index.IndexWriter.PrepareCommitInternal()
at Lucene.Net.Index.IndexWriter.CommitInternal()
问题是并发更新索引引起的,改为以队列方式更新索引后问题就消失了,目前队列用的是 Coravel 的 IQueue,接下来准备基于 dapr 实现(本来就是订阅 dapr 消息更新索引的) https://q.cnblogs.com/q/142679/
就Lucene.Net来说,“Could not find file '_bkd.cfs'”这一错误通常是由于Lucene保存文档和加载文档时出现问题所造成的。可以尝试使用IndexWriter中的RemoveDocument()方法来将文档删除,并使用IndexWriter的AddDocument()方法重新添加一个文档进行更新。
谢谢!我试试