开发者

Why do we use Filters while searching

开发者 https://www.devze.com 2023-01-30 01:20 出处:网络
I am working wi开发者_Python百科th Lucene.My work is to Query nd perform search on it. I want to know the use of Filters.Filters are different from queries in that filters can be cached. Basically, wh

I am working wi开发者_Python百科th Lucene.My work is to Query nd perform search on it. I want to know the use of Filters.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号