For the sorting try (@weight makes sure relevancy is the first sort
order with most relevant first):
:order =>"@weight DESC, expertise DESC"
For the only expert try:
:conditions => {:expert => 3}
On Apr 2, 8:15 pm, Kevin Monk <[email protected]> wrote:
> Apologies for the title. I was thinking for ages before I came up with
> that. I've been racking my brain over this for a few hours now and
> would appreciate any help with this.
>
> I have the following model:
>
> class Person < ActiveRecord::Base
>
> has_many :abilities
> has_many :skills, :through => :abilities
>
> define_index do
> # fields
> indexes [:first_name, :last_name], :as => :name, :sortable => true
> indexes abilities.standard, :as => :expertise, :sortable => true
> # where 3 - Expert, 2 - Intermediate, 1 - Basic
> indexes skills.title, :as => :skills_title
> end
> end
>
> Supposing I have a single search text box and I wanted to search for a
> person who could "juggle" but i'd like to order the results by
> expertise so that the expert jugglers came top. I would like all
> jugglers to be returned as search results but with experts being
> returned at the top. How might I search for this?
>
> Person.search "juggler", :order => :expertise
>
> This isn't going to work as presumably ....
>
> indexes abilities.standard, :as => :expertise, :sortable => true
>
> ... just concatenates all the standards into a single field
> irrespective of whether that ability is in "juggling"
>
> Additionally... How could I set up a condition to only return expert
> jugglers?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Thinking Sphinx" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/thinking-sphinx?hl=en
-~----------~----~----~----~------~----~------~--~---