sphinx MVA与rt_attr_string

时间:2014-06-05 04:01:51

标签: sphinx

我不确定问题标题。但我已经非常努力了。

我的rt_index conf:

type            = rt
path            = C:\nginx\www\public_html\sphinx\scripts\data\rt_index
rt_field        = title
rt_field        = property
rt_attr_string  = title
rt_attr_string  = brand_name
rt_attr_string  = property
rt_attr_multi   = categories
rt_attr_uint    = price
rt_attr_uint    = brand_id

我关注:https://github.com/adriannuta/SphinxFacetingExample

这里有与此类别相关的独特类别和产品数量。 但它只返回类别ID,因为它是" rt_attr_multi"。 我的问题是在这里如何获取带有id的类别的名称? 我创建了另一个类别索引:

index facetcats
{
type            = rt
path            = C:\nginx\www\public_html\sphinx\scripts\data\facetcats
rt_field        = cat_name
rt_attr_string  = cat_name    
}

但无法加入两个索引。

我的目标是在不查询数据库的情况下获取类别名称。

请帮助我。

1 个答案:

答案 0 :(得分:1)

Sphinx没有字符串MVA。 (狮身人面像没有'加入')

坦率地说,你最好的想法是只使用数据库来查找名称。它们将是简单的PK查找,因此速度非常快 - 甚至可以使用memcache或类似的方式缓存查找。

或者您可以使用普通的字符串属性,将其存储为逗号分隔(某些分隔符不要在名称中使用)

主要问题是sphinx会将MVA重新排序为数字顺序(内部),因此您应该在存储到属性之前将类别名称预先分配为id数字顺序。 (所以仍然可以将类别名称与属性中的ID匹配)

相关问题