Why do we use Filters while searching
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.
精彩评论