Mat*_*att 5 .net lucene lucene.net
在 lucene 中,我可以执行以下操作
doc.GetField("mycustomfield").StringValue();
Run Code Online (Sandbox Code Playgroud)
这将检索索引文档中列的值。
我的问题,同样的'doc',有没有办法得到Doc. Id?卢克展示了它,因此必须有办法解决这个问题。我需要它来删除有关更新的文档。
我搜索了文档,但没有找到在 GetField 中使用的术语,或者是否已经有另一种方法。
事实证明你必须这样做:
var hits = searcher.Search(query);
var result = hits.Id(0);
Run Code Online (Sandbox Code Playgroud)
相对于
var results = hits.Doc(i);
var docid = results.<...> //there's nothing I could find there to do this
Run Code Online (Sandbox Code Playgroud)