思考狮身人面像中是否可以通过关联列对搜索结果进行排序?
我的索引定义如下:
ThinkingSphinx::Index.define :demand, :with => :active_record, :delta => true do
indexes client(:name), as: :client, sortable: true
has(created_at, updated_at, client_id)
end
搜索在控制器中执行:
Demand.search(params[:query], order: "#{params[:sort]} #{params[:direction].try(:upcase)}")
的值params[order]
是"client.name"
,params[:direction]
要么是"asc"
要么"desc"
这是 sphinx 生成的查询:
SELECT * FROM `demand_core`, `demand_delta` WHERE MATCH('Test_client @sphinx_internal_class_name (Demand)') AND sphinx_deleted = 0 ORDER BY client.name DESC LIMIT 0, 20
当我执行搜索时,我收到以下错误:
ThinkingSphinx::SyntaxError - sphinxql: syntax error, unexpected CONST_FLOAT, expecting $end near '.name DESC LIMIT 0, 20; SHOW META':
我一直在寻找解决方案,但找不到。所以问题是我如何在执行搜索后在 sphinx 中应用排序?