简体   繁体   English

使用模型字段“得分”对黑子进行排序

[英]sunspot solr sort using model field “score”

I am new in ROR. 我是ROR新手。 Sunspot solr search giving me headache. 太阳黑子的搜索使我头疼。 I am sorting with field "score" and it is belongs to the child table and It's not giving the result. 我正在对字段“得分”进行排序,它属于子表,并且没有给出结果。 I have verified the solr query and it appending data type with the field name 我已经验证了solr查询并将其与字段名称一起附加到数据类型中

float => _f , string => _s and Integer => _i float => _f,字符串=> _s和Integer => _i

Eg: field model Age = sort: "age_f desc" 例如:字段模型Age = sort:“ age_f desc”

But for score it is coming like sort: "score desc" 但是对于得分,它却像是排序:“ score desc”

Yes I understood "score" is some keyword in solr. 是的,我了解“分数”是solr中的一些关键字。 But I have to use "score" as my field name as well.. 但是我也必须使用“分数”作为我的字段名称。

Please any one help me for it. 请任何人帮我。

I found a solutions for it. 我找到了解决方案。 We have to add alias_attribute in model. 我们必须在模型中添加alias_attribute。

alias_attribute :searchable_score, :score alias_attribute:searchable_score,:score

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM