Thank you Pat!  This worked perfectly!  I very much appreciate your
help!

On Sep 10, 7:19 pm, Pat Allan <[email protected]> wrote:
> Hi David
>
> Something like this is probably possible using :sphinx_select to create a new 
> attribute on the fly, and then sort by it first, otherwise weight.
>
>   priority_value = 5
>   Model.search 'a*',
>     :sphinx_select => "*, IF(my_attribute = #{priority_value}, 1, 0) AS 
> priority",
>     :order         => 'priority DESC, @weight DESC'
>
> Keep in mind that this won't work for string attributes, as Sphinx doesn't 
> let you filter by them.
>
> --
> Pat
>
> On 09/09/2011, at 5:18 AM, David Worth wrote:
>
>
>
>
>
>
>
> > Hello All,
>
> > Apologies if I have not read the appropriate FAQ for this group (I
> > looked and failed) before posting this question.
>
> > I'm attempting to use TS in what is to my mind, a complicated
> > fashion.  I have a field and an attribute and I would like the search
> > results sorted in the following fashion:  If a parameter passed to my
> > search matches (exactly) the attribute I would like it's result
> > "promoted" within the search results such that it appears first, then
> > within those results matching the attribute, and those not, I would
> > like the sort by @weight as expected.
>
> > An example may help, given the following data where the first column
> > is the indexed field and the second is the attribute:
>
> > "arizona", "A"
> > "ariba", "B"
> > "a", "B"
> > "atlantic", "C"
>
> > the query searching for "a" with the attribute set to "B" would
> > produce the following results (where the order of "a" and "ariba" is
> > not important):
>
> > "a", "B"
> > "ariba", "B"
> > "arizona", "A"
> > "atlantic", "C"
>
> > Is this feasible within Sphinx and/or ThinkingSphinx?  Are there
> > examples of such a sort order that I've missed in my google searches?
>
> > Thank you for your time,
> > Dave
>
> > --
> > 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 
> > athttp://groups.google.com/group/thinking-sphinx?hl=en.

-- 
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