Hey Kevin,

Sorry I misunderstood your question (i.e - skipped over the important
details :) ).

You may want to look into multi-valued attributes:
http://www.sphinxsearch.com/docs/current.html#mva.  In Thinking Sphinx
you specify them using the :has syntax.

The one catch is the MVAs must be integers.

So you could add:

has abilities.id, :as => :experience_levels

And add:

:conditions => {:experience_levels => 3}

to your search options to get you Persons who are at least an expert
in one thing.

You could also add:

has skills(:id), :as => :skill_ids

And then get back a list of all the skill ids the person has which
could also be used for conditions or faceting.

You can also sort your results like I said before to put someone who
is an experts (in any skill) first:

:order =>"@weight DESC, experience_levels DESC"

This isn't exactly what you are asking but might get you closer :)

Tom


On Apr 6, 6:34 pm, Kevin Monk <[email protected]> wrote:
> Thanks for your response Tom, I don't think that this would work
> though as all the skills would be concatenated into a single field and
> so would the expertise. I imagine that a record returned would look
> something like this:
>
> Name: Joe Bloggs
> Skills: Eating Juggling Fishing German Kung Fu
> Expertise: 3 1 2 2 3
>
> Joe Bloggs is great at eating and he's great at Kung Fu but if I
> search for "Joe Bloggs", Eating or "Kung Fu" then he should be
> appearing near the top. With the concatenated fields there's no way to
> match up Kung Fu with the 3 or Juggling with the 1. If I order by the
> expertise then it's merely going to return.... well I don't know what
> it'll return but there's no method of identifying the skill with the
> expertise. If I do skills search i.e. Skill.search "juggling", :order
> => expertise then this would work because I'd have an array of the
> skills and expertise but I also want to search by name which is in the
> parent (Person) model.
>
> The end result is that I want an array of people with either that
> name, or those skills.
>
> I'm starting to think that my best best is to search Skills and group
> by the foreign key - person id. Then retrieve those people and combine
> them with a seperate People.search "keywords". I've seen that you can
> do a multiple class search but I only want one class type (People) to
> be in the search results.
>
> Confused? I am.
>
> If I sort this out then I'd be happy to write it up as a Blog Post for
> other developers.
>
> On Apr 5, 8:00 pm, Tom Davies <[email protected]> wrote:
>
> > 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to