2

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?

miccet
  • 1,870
  • 3
  • 19
  • 26

1 Answers1

6

You can use SPH_SORT_EXTENDED mode for this:

$sph->SetSortMode(SPH_SORT_EXTENDED, "Project ASC, Company ASC");

(sort mode docs)

Edit: above example is PHP but it appears that Thinking Sphinx exposes the feature similarly:

Article.search "term", :sort_mode => :extended,
  :order => "Project ASC, Company ASC"
Ben Regenspan
  • 10,058
  • 2
  • 33
  • 44