带有docIds的Lucene过滤器

编程入门 行业动态 更新时间:2024-10-25 20:28:40
本文介绍了带有docIds的Lucene过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我试图做到以下几点:我想通过分别查询每个字段来创建一个候选集合,然后将最前面的k个匹配添加到这个集合中。完成之后,我需要在这个候选集上运行另一个查询。 我现在如何实现它的方式是使用QueryWrapperFilter和一个BooleanQuery匹配每个候选文档的唯一id字段。但是,这意味着我必须先为每个候选文档调用IndexSearcher.doc()。get(docId),然后才能将其添加到我的BooleanQuery中,这是主要的瓶颈。我只是通过MapFieldSelector(docId)加载docId字段。我想创建自己的Filter类,但是我不能使用内部的Lucene doc ID直接,因为它们是每段指定的。任何想法如何解决这个问题?解决方案

该字段(它可能已经是),并使用 FieldCache 以更快的速度检索docId,而不是在布尔查询中使用docIds,可以使用 TermsFilter 或 FieldCacheTermsFilter 。后面的文档描述了性能的权衡。

I'm trying to do the following: I want to create a set of candidates by querying each field separately and then adding the top k matches to this set. After I'm done with that, I need to run another query on this candidate set. The way how I implemented it right now is using a QueryWrapperFilter with a BooleanQuery that matches the unique id field of each candidate document. However, this means I have to call IndexSearcher.doc().get("docId") for each candidate document before I can add it to my BooleanQuery, which is the major bottleneck. I'm only loading the docId field via MapFieldSelector("docId).

I wanted to create my own Filter class, but I can't use the internal Lucene doc ids directly, because they are specified per segment. Any thoughts on how to approach this?

解决方案

Instead of reading the stored docId, index the field (it probably already is) and use the FieldCache to retrieve docIds much faster. Then instead of using the docIds in a BooleanQuery, try using a TermsFilter or FieldCacheTermsFilter. The latter documentation describes the performance trade-offs.

更多推荐

带有docIds的Lucene过滤器

本文发布于:2023-10-13 20:34:22,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:过滤器   docIds   Lucene

发布评论

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

>www.elefans.com

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