【问题标题】:Search multi value category tree in Solr (with left/right)在 Solr 中搜索多值类别树(左/右)
【发布时间】:2013-02-04 16:48:01
【问题描述】:

我使用 Solr 来存储产品。每个产品可以有多个类别。

<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" /> 
<field name="sku" type="text_en_splitting_tight" indexed="true" stored="true" omitNorms="true"/>
<field name="cat" type="string" indexed="true" stored="true" multiValued="true"/>
<field name="cat_left" type="int" indexed="true" stored="true" multiValued="true"/>
<field name="cat_right" type="int" indexed="true" stored="true"  multiValued="true"/>

我想查找属于某个类别和以下子类别的所有产品。为了避免递归搜索,我为每个类别节点计算 LEFT/RIGHT 值。在 SQL 数据库中它运行良好。示例查询如下所示:

SELECT * FROM Products p JOIN Categories c WHERE c.left > 2 AND c.right < 8

我不能在 Solr 中做同样的事情,因为多个 left 和 right 值没有配对。如果我有 2 对分配给一个产品:

{left: 2, right: 3}
{left: 6, right: 8}

我会查询:

+cat_left:[4 TO *] +cat_right:[* TO 5]

很明显会返回该产品,因为最小的左侧值为 2,而最右侧的值为 8。Solr 不知道对于 left 等于 2 right end on 3。这些字段没有关联。

我喜欢左/右方法,因为它是查询树的快速方法,但是否可以将它与 Solr 一起使用?也许我过于复杂了,Solr 有很好的树支持?

【问题讨论】:

    标签: solr


    【解决方案1】:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-07-23
      • 1970-01-01
      • 1970-01-01
      • 2010-09-29
      • 1970-01-01
      • 2017-07-23
      • 1970-01-01
      相关资源
      最近更新 更多