首页 新闻 会员 周边 捐助

Lucene.Net: 删除文档后更新文档时报错"Could not find file '_bkd.cfs'"

0
悬赏园豆:30 [已解决问题] 解决于 2023-02-22 16:46

从索引中删除一个文档后,通过 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()
dudu的主页 dudu | 高人七级 | 园豆:30939
提问于:2023-02-20 07:28
< >
分享
最佳答案
0

问题是并发更新索引引起的,改为以队列方式更新索引后问题就消失了,目前队列用的是 Coravel 的 IQueue,接下来准备基于 dapr 实现(本来就是订阅 dapr 消息更新索引的) https://q.cnblogs.com/q/142679/

dudu | 高人七级 |园豆:30939 | 2023-02-22 16:45
其他回答(1)
0

就Lucene.Net来说,“Could not find file '_bkd.cfs'”这一错误通常是由于Lucene保存文档和加载文档时出现问题所造成的。可以尝试使用IndexWriter中的RemoveDocument()方法来将文档删除,并使用IndexWriter的AddDocument()方法重新添加一个文档进行更新。

收获园豆:30
天道茜 | 园豆:241 (菜鸟二级) | 2023-02-21 14:14

谢谢!我试试

支持(0) 反对(0) dudu | 园豆:30939 (高人七级) | 2023-02-21 14:22
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册