使用子字段的 Rails3 SOLR 排序顺序 [英] Rails3 SOLR sort order using a child field

查看:40
本文介绍了使用子字段的 Rails3 SOLR 排序顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Rails 3 应用程序中使用 SOLR 进行了有效搜索.我的控制器以 pubdate 顺序返回结果.我正在尝试按 Section.name 进行子订购.如何将子字段添加到 order-by 语法中?

I have a working search using SOLR in a Rails 3 app. My controller returns results in pubdate order. I am trying to sub-order by the Section.name. How can I add the child field to the order-by syntax?

这是我的代码:

@stories = Story.search do
    paginate(:page => params[:page])
    order_by :pubdate, :desc
    order_by :section_id                <---want to suborder by Section.name
    fulltext params[:search_query]
end

推荐答案

您需要将部分名称添加到父字段才能使用部分名称对其进行排序.
您可以检查任何 JIRA 的 Solr Join 功能以启用对子字段的排序.

You would need to add the section name to the parent field to be able to sort it using the Section name.
You can check on Solr Join feature for any JIRA to enable sorting on the Child fields.

文档提及:-

对于习惯 SQL 的人来说,需要注意的是 Joins inSolr 并不真正等同于 SQL 连接,因为没有信息关于被加入的表来自"被结转到决赛结果.更合适的 SQL 类比是内部查询"

For people who are used to SQL, it's important to note that Joins in Solr are not really equivalent to SQL Joins because no information about the table being joined "from" is carried forward into the final result. A more appropriate SQL analogy would be an "inner query"

这篇关于使用子字段的 Rails3 SOLR 排序顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆