获取Lucene的Doc ID(Getting the Doc ID in Lucene)

编程入门 行业动态 更新时间:2024-10-28 12:16:51
获取Lucene的Doc ID(Getting the Doc ID in Lucene)

在lucene,我可以做以下事情

doc.GetField("mycustomfield").StringValue();

这将检索索引文档中列的值。

我的问题,对于同一个'doc' ,是否有办法获得Doc. Id Doc. Id ? 卢克显示它,因此必须有办法解决这个问题。 我需要它删除更新文件。

我搜索了文档,但没有找到在GetField中使用的术语,或者是否已经有另一种方法。

In lucene, I can do the following

doc.GetField("mycustomfield").StringValue();

This retrieves the value of a column in an index's document.

My question, for the same 'doc', is there a way to get the Doc. Id ? Luke displays it hence there must be a way to figure this out. I need it to delete documents on updates.

I scoured the docs but have not found the term to use in GetField or if there already is another method.

最满意答案

事实证明你必须这样做:

var hits = searcher.Search(query); var result = hits.Id(0);

相反

var results = hits.Doc(i); var docid = results.<...> //there's nothing I could find there to do this

Turns out you have to do this:

var hits = searcher.Search(query); var result = hits.Id(0);

As opposed to

var results = hits.Doc(i); var docid = results.<...> //there's nothing I could find there to do this

更多推荐

本文发布于:2023-07-23 04:43:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1227584.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Lucene   Doc   ID

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!