Actually, I think the most direct approach is to weight the field by
briefest length of description. So "carrots, raw" always comes up
before "babyfoods, carrots" for query='carrots'. of course
query='babyfoods carrots' should turn up the latter before "carrots,
raw".
In this case, the "name" is the description. Other indexes are simply
"common name", "scientific name", etc. The "description" is the only
field I need to sort.
Thanks
On Oct 19, 9:12 am, Pat Allan <[EMAIL PROTECTED]> wrote:
> Hi Jesse
>
> Do you want to sort by a specific field? Or is it more a matter of
> weighting results?
>
> If you want to sort by product name (which is a guess, I'm not sure
> what your schema is), then you'll just need to add :sortable => true
> to the name field, and then :order => :name in your search queries. If
> you want name weighted more than, say, description, you can do that
> one of two ways. To enforce it for every query on the model, add
> something like the following to your define_index block:
> set_property :field_weights => {:name => 10, :description => 5}
>
> You can also pass in the field_weights option, defined the same way,
> into your search calls, to have it effective only for that search.
>
> Hope this helps.
>
> Cheers
>
> --
> Pat
> e: [EMAIL PROTECTED] || m: +614 1327 3337
> w:http://freelancing-gods.com|| t: twitter.com/pat
> discworld:http://ausdwcon.org|| skype: patallan
>
> On 19/10/2008, at 8:49 PM, Jesse wrote:
>
>
>
> > Hello, first let me say thanks to the developers for this wonderful
> > tool. Before I plugged this in via the RailsCast episode, I never
> > would have dreamed that I could have something like this at my
> > fingertips :-)
>
> > Stage two, search is working fine, but for my app, the search queries
> > 7519 food records, and BABYFOODS come up first in the database, and I
> > would like to move the briefer and adult foods to the top.
>
> > I.e., a searching for "apples" should yield "Apples, raw, with skin"
> > and "Apples, raw, without skin" before longer results such as brand
> > names and processed foods.
>
> > Is there a quick solution?
>
> > Set all the indexes ':sortable => true' and work from there? Or is it
> > more complicated?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---