Is it that you want partial word or wildcard matching?
http://freelancing-god.github.com/ts/en/common_issues.html#wildcards

Also, to automatically apply wildcards to your searches, use the :star => true 
option in your search call.

-- 
Pat

On 17/08/2012, at 7:54 PM, frankphilips wrote:

> Nvm, I fixed the sortable links.....it was an issue in my models.
> Still trying to fix the ajax search though. Thanks for your help.
> 
> -Frank
> 
> On Aug 17, 1:51 pm, frankphilips <[email protected]> wrote:
>> Also my Ajax search is all messed up :-/
>> 
>> It doesn't sort per key any more...Only when I type the whole
>> string ...eg: "Macbook"
>> 
>> On Aug 17, 1:42 pm, "Pat Allan" <[email protected]> wrote:
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>>> Looks like your sort_direction method isn't returning the right details - 
>>> should be ASC or DESC, much like SQL. Can you confirm what the generated 
>>> value for the :order option is?
>> 
>>> --
>>> Pat
>> 
>>> On 17/08/2012, at 7:38 PM, frankphilips wrote:
>> 
>>>> Did that, but now I'm getting this:
>> 
>>>> index shruffle_core: invalid sorting order 'desc_sort'
>> 
>>>> On Aug 17, 12:29 pm, "Pat Allan" <[email protected]> wrote:
>>>>> Have you re-indexed Sphinxand restarted the daemon since making those 
>>>>> changes? If not, one task does it all: rake ts:rebuild
>> 
>>>>> Cheers
>> 
>>>>> --
>>>>> Pat
>> 
>>>>> On 17/08/2012, at 17:34, frankphilips <[email protected]> wrote:
>> 
>>>>>> Hi Pat,
>> 
>>>>>> I took your advice and incorporated your exact code.  I've also read up 
>>>>>> on attributes and fields and have fixed accordingly. However, now I'm 
>>>>>> getting this error:
>> 
>>>>>> "index shruffle_core: sort-by attribute 'created_at' not found"
>> 
>>>>>> I do have has created_at in my model.What am I doing wrong now? Thanks 
>>>>>> for the help!
>> 
>>>>>> -Frank
>> 
>>>>>> On Thursday, August 16, 2012 7:03:56 PM UTC-5, Pat Allan wrote:
>>>>>> Hi Frank
>>>>>> The .order method on models is for SQL queries, not Sphinx searches, so 
>>>>>> you can't mix the two together. If you want to use sort_column and 
>>>>>> sort_direction, then pass the string you're building with the :order 
>>>>>> option (which it seems you're currently doing with :created_at):
>> 
>>>>>>   Shruffle.search params[:search], :order => "#{sort_column} 
>>>>>> #{sort_direction}"
>> 
>>>>>> Also, I'd recommend reading up on the differences between attributes and 
>>>>>> fields - you probably don't want/need price, org_percent or created_at 
>>>>>> to be fields. Attributes are inherently sortable (indeed, when fields 
>>>>>> are marked as sortable, Thinking Sphinx is just creating an attribute in 
>>>>>> the background to fulfil that purpose).
>>>>>> http://freelancing-god.github.com/ts/en/sphinx_basics.html
>> 
>>>>>> Hope this helps.
>> 
>>>>>> --
>>>>>> Pat
>> 
>>>>>> On 16/08/2012, at 3:22 PM, frankphilips wrote:
>> 
>>>>>>> Hi,
>> 
>>>>>>> I'm a noob to Rails, and I need some help. In Railscast 240, Ryan talks 
>>>>>>> about creating sortable table columns with ajax 
>>>>>>> search:http://railscasts.com/episodes/240-search-sort-paginate-with-ajax
>> 
>>>>>>> However when I try to combine Thinking Sphinx rather then using the 
>>>>>>> standard search Ryan mentions, it breaks my sortable table columns. I'm 
>>>>>>> sure there is a quick way to fix this. Please help! Thanks :)
>> 
>>>>>>> Here's my code:
>> 
>>>>>>> MODEL:
>> 
>>>>>>> define_index do
>> 
>>>>>>>           indexes :title, sortable: true
>>>>>>>           indexes :desc, sortable: true
>>>>>>>           indexes email
>>>>>>>           indexes :org, sortable: true
>>>>>>>           indexes org_percent
>>>>>>>           indexes :price, sortable:true
>>>>>>>           indexes :city, sortable: true
>>>>>>>           indexes :created_at, sortable: true
>> 
>>>>>>>           has created_at, updated_at
>> 
>>>>>>>         end
>> 
>>>>>>> CONTROLLER:
>> 
>>>>>>> helper_method :sort_column, :sort_direction
>>>>>>>  def index
>>>>>>>    @shruffles = Shruffle.order(sort_column + ' ' + 
>>>>>>> sort_direction).search(params[:search], :order => :created_at,
>>>>>>>  :sort_mode => :desc)
>> 
>>>>>>> APPLICATION HELPER:
>> 
>>>>>>> def sortable(column, title = nil)
>>>>>>>    title ||= column.titleize
>>>>>>>    css_class = (column == sort_column) ? "current #{sort_direction}" : 
>>>>>>> nil
>>>>>>>    direction = (column == sort_column && sort_direction == "asc") ? 
>>>>>>> "desc" : "asc"
>>>>>>>    link_to title, {:sort => column, :direction => direction}, {:class 
>>>>>>> => css_class}
>>>>>>>          end
>> 
>>>>>>> VIEW:
>> 
>>>>>>> <%= hidden_field_tag :direction, params[:direction] %>
>>>>>>> <%= hidden_field_tag :sort, params[:sort] %>
>> 
>>>>>>> <table class="pretty">
>>>>>>>           <tr align="left">
>> 
>>>>>>>             <th><%= sortable "title" %></th>
>>>>>>>             <th><%= sortable "price" %></th>
>>>>>>>             <th><%= sortable "city"  %></th>
>>>>>>>             <th><%= sortable "org", 'Non-Profit' %></th>
>>>>>>>             <th><%= image_tag "ico-heart.png" %> <%= sortable 
>>>>>>> "org_percent", 'Donation %' %></th>
>>>>>>>             <th><%= sortable "created_at", 'Date' %></th>
>>>>>>>           </tr>
>> 
>>>>>>>             <% for shruffle in @shruffles %>
>> 
>>>>>>>                   <tr>
>>>>>>>                     <td><%= link_to shruffle.title, shruffle %></td>
>>>>>>>                     <td class="price"><%= 
>>>>>>> number_to_currency(shruffle.price) %></td>
>>>>>>>                     <td><%= shruffle.city %></td>
>>>>>>>                     <td><%= shruffle.org %></td>
>>>>>>>                     <td><%= shruffle.org_percent %>%</td>
>>>>>>>                     <td><%= shruffle.created_at.strftime("%b %d, %Y") 
>>>>>>> %></td>
>>>>>>>                   </tr>
>>>>>>>           <% end %>
>>>>>>> </table>
>> 
>>>>>>> -Frank
>> 
>>>>>>> --
>>>>>>> You received this message because you are subscribed to the Google 
>>>>>>> Groups "Thinking Sphinx" group.
>>>>>>> To view this discussion on the web 
>>>>>>> visithttps://groups.google.com/d/msg/thinking-sphinx/-/Ls4y1X2qT5YJ.
>>>>>>> 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 view this discussion on the web 
>>>>>> visithttps://groups.google.com/d/msg/thinking-sphinx/-/zvniTZRgm4QJ.
>>>>>> 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 
>>>> 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.
> 



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