0
如何获取已定义的思维_sphinx属性和模型上的字段列表? 我特别要检查输入属性是否为狮身人面像获取由thinking_sphinx定义的字段和属性
例如定义来定义:
has store.name, :as => :store_name
我想是这样Model.sphinx_attributes.include? :store_name
如何获取已定义的思维_sphinx属性和模型上的字段列表? 我特别要检查输入属性是否为狮身人面像获取由thinking_sphinx定义的字段和属性
例如定义来定义:
has store.name, :as => :store_name
我想是这样Model.sphinx_attributes.include? :store_name
下应该做的伎俩:
Model.sphinx_indexes.collect { |index|
index.attributes.collect &:unique_name
}.flatten.include?(:store_name)
字段大致相同:
Model.sphinx_indexes.collect { |index|
index.fields.collect &:unique_name
}
无论是在跑步前,这是很好的做法是先运行此,为保证指标加载:
Model.define_indexes
如果他们已经加载,该方法不会做任何事情。
非常感谢,工作。请添加回答,首先应该使用define_indexes(正如你在这里注意到的那样:[github issue 65](https://github.com/freelancing-god/thinking-sphinx/issues/65)) –
我记得只需要20分钟以前 - 很高兴看到你想出了它:) – pat