为什么我们在搜索时使用过滤器 [英] Why do we use Filters while searching

查看:95
本文介绍了为什么我们在搜索时使用过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在与Lucene合作.我的工作是查询和执行搜索.我想知道过滤器的用法.

I am working with Lucene.My work is to Query nd perform search on it. I want to know the use of Filters.

推荐答案

过滤器与查询的不同之处在于可以缓存过滤器.基本上,当您使用过滤器时,Lucene会存储一个位图,如果第i个文档与过滤器匹配,则位i为1,否则为0.

Filters are different from queries in that filters can be cached. Basically, when you use a filter, Lucene stores a bitmap, where bit i is 1 if the ith document matches the filter, and 0 otherwise.

如果搜索与查询和过滤器匹配的所有内容,它将获得查询结果,并将其与缓存的过滤器按位与.在某些情况下,这可以提高性能.

If you do a search for everything that matches a query and a filter, it will get the results of the query and bitwise-AND it with the cached filter. This can improve performance in some circumstances.

基本上,如果您有一个或两个条件都需要应用于几乎所有搜索(例如,隐藏高安全性"的所有文档),那么您可能需要调查过滤器.否则,仅执行常规查询会更好,因为过滤器会占用大量内存.

Basically, if you have one or two conditions that need to apply to almost every search (e.g. hide all documents which are "high security") then you might want to look into filters. Otherwise, just doing normal queries should perform better, since filters can take up a lot of memory.

这篇关于为什么我们在搜索时使用过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆