Home  >  Article  >  Backend Development  >  类似京东目录的filter如何处理好

类似京东目录的filter如何处理好

WBOY
WBOYOriginal
2016-06-06 20:37:02909browse

类似京东目录的filter如何处理好

类似于京东的这种filter是如何处理的,自己在模仿的过程中是先到数据库中获得相应的filter,然后根据传递的产品进行标红操作,但是感觉这种效率肯定不会高(到数据库查出来就为了加个color:red;),不知道有没有什么更好的方法。

回复内容:

类似京东目录的filter如何处理好

类似于京东的这种filter是如何处理的,自己在模仿的过程中是先到数据库中获得相应的filter,然后根据传递的产品进行标红操作,但是感觉这种效率肯定不会高(到数据库查出来就为了加个color:red;),不知道有没有什么更好的方法。

商品分类基本上万年不变,数据库里存一下。然后后台或系统自动生成缓存。

比如:

<code>json</code><code>{
    "id122":"华硕"
}
</code>

代码里循环分类。url里获取当前选中分类。

<code>for cate in category_array_from_json:
    if (category_array_from_json[cate] == url.get('id')):
        标红
</code>

Ps: 这种多标签搜索一般都是上Sphinx/Solr/Luence/Elasticsearch了,不会走数据库的

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn