思考 sphinx 在多个字段上排序
我正在寻找模型项目。项目属于公司,因此列表中的所有项目都可以附加相同的公司。结果列表的示例:
CompanyA - ProjectA
CompanyA - ProjectO
CompanyA - ProjectC
CompanyA - ProjectB
CompanyB - ProjectU
CompanyB - ProjectI
我可以按项目名称排序,但公司名称列可以像上面一样是随机的。我想将此列排序为辅助字段。这可以做到吗?我读过Sphinx正在将字段排序转换为id,可能是为了节省内存,但这不可能以这种方式限制排序?
I am searching for the model Projects. Projects belongs_to Companies, so all Projects in the list can have the same Company attached to it. An example of a result list:
CompanyA - ProjectA
CompanyA - ProjectO
CompanyA - ProjectC
CompanyA - ProjectB
CompanyB - ProjectU
CompanyB - ProjectI
I can sort on Project name, but then the Company name column can be random like above. I would like to sort this column as secondary field. Can this be done? I have read that Sphinx is converting the fields sorting to an id, probably to save memory, but this can't possibly limit the sorting in this way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以为此使用 SPH_SORT_EXTENDED 模式:(
排序模式文档)
编辑:上面的例子是PHP,但看起来 Thinking Sphinx 类似地公开了该功能:
You can use SPH_SORT_EXTENDED mode for this:
(sort mode docs)
Edit: above example is PHP but it appears that Thinking Sphinx exposes the feature similarly: