Lucene倒排索引访问计数

发布于 2025-01-01 11:18:36 字数 624 浏览 5 评论 0原文

在Lucene中,我想了解倒排索引的访问次数。

也许,Lucene有这样的倒排索引,

猫狗
----- -----
d01 d02
d02 d01
d03 d03
----- -----

如果我使用查询“猫狗”,Lucene将连续访问倒排索引。 然后我问top-2结果,只有4次访问Lucene将返回d01,d02。 在这种情况下,我想知道访问时间(在本例中为“4”)。

目前我是这样使用Lucene的。

Query q = new QueryParser(Version.LUCENE_35, "title", analyzer).parse(querystr);
int hitsPerPage = 10;
IndexSearcher searcher = new IndexSearcher(index, true);
TopScoreDocCollector collector = TopScoreDocCollector.create(hitsPerPage, true);
searcher.search(q, collector);
ScoreDoc[] hits = collector.topDocs().scoreDocs;

谢谢。

In Lucene, I want to know about the number of accesses in inverted index.

Maybe, Lucene has the inverted index like this,

cat dog
----- -----
d01 d02
d02 d01
d03 d03
----- -----

If I use query "cat dog", Lucene will access the inverted index consecutively.
I ask top-2 result then, with only 4 accesses Lucene will return d01, d02.
In that case, I want to know the access time (in this example "4").

Currently, I use Lucene like this.

Query q = new QueryParser(Version.LUCENE_35, "title", analyzer).parse(querystr);
int hitsPerPage = 10;
IndexSearcher searcher = new IndexSearcher(index, true);
TopScoreDocCollector collector = TopScoreDocCollector.create(hitsPerPage, true);
searcher.search(q, collector);
ScoreDoc[] hits = collector.topDocs().scoreDocs;

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

失退 2025-01-08 11:18:36

渐近地,如果有 p 匹配项并且您找到了前 k,则时间将为 p log k。因此,在您的情况下,6 log 2 = 6。 (当然,对于如此小的数字,这个公式给出了荒谬的结果)。

有关详细信息,请参阅

请注意,“前两名”并不意味着“前两名”,而是“得分最高的两个”。根据示例中的权重,Lucene 可能会忽略 d03。

Asymptotically, if there are p matches and you're finding the top k, the time will be p log k. So in your case, 6 log 2 = 6. (Of course with such small numbers, this formula gives ridiculous results).

See this for more info.

Note that "top two" doesn't mean "first two", but rather "two highest scoring". Depending on the weights in your example, it's possible that Lucene could ignore d03.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文