Dmoz/Monster algorithme to calculate count of each category and sub category?

廉价感情. 提交于 2020-01-06 06:12:46

问题


I have to create a browse page like monter.com or dmoz directory. My problem is the counts for each category. What's the best practive to do a similar thing? I am using PHP/MySQL Thx!


回答1:


Did you try to implement it the way that you calculate these numbers dynamically when the page loads? How do you know that it is indeed a performance issue? Calculations are pretty fast these days.

Otherwise put a counter field next to each (sub-)category. When inserting(/deleting) a new post, then you update the counter of all categories it belongs to.

As a result, when you query any category, or set of categories, you will have a counter field for each giving the exact numbers of posts the category holds.




回答2:


Solr can do that with Faceted Search http://lucene.apache.org/solr/tutorial.html#Faceted+Search I'll test it now.



来源:https://stackoverflow.com/questions/3100386/dmoz-monster-algorithme-to-calculate-count-of-each-category-and-sub-category

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!