I am using ThinkingSphinx in an application and right now I am not doing any type of order on my results. However, I would like to make this an option via a link someone can click on the page and it just passes it through the URL to ‘refresh’ the page with the results now ordered.
In the .search parameters I tried doing :order => params[:o] then in the URL passing o=columnname but that does not seem to work.
Just to note, when I hard-code the ordering it works fine, I’m not having trouble with indexing/making a DB column sortable. I would just like to make it so via a URL argument it the results can be displayed ordered.
According to the Sphinx documentation, the fields you want to use for sorting must be flagged as sortable. Attributes defined with
hasdo not have to be flagged, because all attributes are sortable:Then one can use the
:orderand:sort_modeparameter to define the sort order: