开发者

Facet on Range or Boolean

开发者 https://www.devze.com 2023-02-14 12:33 出处:网络
In my Solr schema I have a field called TotalReviews which shows the number of reviews of the docuement. Now I would like to have a facet that shows the number of documents with/without reviews.

In my Solr schema I have a field called TotalReviews which shows the number of reviews of the docuement. Now I would like to have a facet that shows the number of documents with/without reviews. I think I can take two approaches here: Either I can have a facet on range [0:TO:0] and [1:TO:*] on TotalReviews field, or I can add another boolean field to the schema like HasReviews and at the time of indexing, index true or false based on TotalReviews and then facet on this field. Which approach you think will perform better?

If I want to use HasReviews field approach, is there a way to use CopyField feature to store and index true in this field when TotalReviews is greater than zero and false if it is zero, co开发者_开发百科nsidering TotalReviews field type is string?

Thanks.


I think the simplest solution will be to facet on range [0 TO 0] to get the number of documents without reviews. Subtract this number from the total results to get the number of documents with reviews. This way we can avoid faceting on the range [1 TO *].

0

精彩评论

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

关注公众号