如何根据字段的权重对字段(在模板中)进行排序?
我使用thinking_sphinx进行搜索,并且我正在尝试获取输出表,其中字段根据权重进行分组(来自set_property:field_weights)
此define_block
define_index do
indexes status, title, content, manager, note, start_date, end_date
has created_at, updated_at, parent_id, organization_id
has user_id, :as => :user_id, :type => :integer
has '7', :as => :model_order, :type => :integer
set_property :field_weights => {
:title => 1,
:start_date => 2,
:user_id => 7
}
set_property :delta => true
end
如何根据字段的权重对字段(在模板中)进行排序?
I use thinking_sphinx for search, and i'm trying to get the output table in which fields are grouped according to weight(from set_property :field_weights)
This define_block
define_index do
indexes status, title, content, manager, note, start_date, end_date
has created_at, updated_at, parent_id, organization_id
has user_id, :as => :user_id, :type => :integer
has '7', :as => :model_order, :type => :integer
set_property :field_weights => {
:title => 1,
:start_date => 2,
:user_id => 7
}
set_property :delta => true
end
How to sort the field (in the template) depending on their weight?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定我是否理解问题,但似乎您正在尝试从视图中读取 field_weights 的配置...
我不知道 Thinking_sphinx 是否有方法可以做到这一点,但我要做的就是保存该配置并在需要的地方使用它...
然后在您看来,您可以使用 YourModel::FieldWeights 显示中的字段它们的权重顺序,例如:
I'm not sure if I understand the Q, but it seems that you are trying to read the configuration of the field_weights from the view...
I don't know if thinking_sphinx has a method to do that, but what I would do is save that configuration elsewere and use it where you need it...
Then in your view you can use YourModel::FieldWeights to display the fields in order of their weights, for example: