开发者

Lucene.NET: Query or Filter?

It is my understanding that documents are found based on a query, and then that result is then filtered by the 开发者_高级运维filter.

The Query is the only that that will effect the score/relevance of a document.

Would there be any performance (caching) improvements if I query results that have relevance towards relevancy, and filter items that don't?

Here is my situation. I have a lot of products, and the website will often search for products by category or manufacturer. I was thinking about using queries for that as that will bring the products down to a smaller subset which can be cached. I can then filter my results by product specifications. Should I use filters for specifications? That way we can filter based on an already cached (by lucene) subset of products (category or manufacturer).


Using filters also does not affect the returned score whereas additional terms in a query do. You should use filters, for example, if a user picks a certain category from a list of available categories as facets :

  • Category : Electricals
  • Query Terms : DSLR Camera

Resultant scores (relevancy) are based on the query terms other than a hit on the category


The difference between filter and query is mostly that filter is exact. If you filter on brand=... than you will only get that exact brand. If you query on it, you will get the brand and possibly other results that also match your query.

So the question is, do you want an exact filter, or is it just for relevance?


Filtering provides a mechanism to further restrict the results of a query and provide a possible performance gain if the same query is run multiple times. We mostly use filters for security - this would provide performance gains as results of the query are cached.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜