You'll need to restart Sphinx whenever you change the structure of your indices (or add a new index) - have you done that as well as re-index?
-- Pat On 11/08/2011, at 11:17 PM, mikeee wrote: > One more quick question. > > The first index_weights approach worked reasonably well but now I'm > attempting to use your second suggestion and am getting the following: > > index country_core: sort-by attribute 'class_sort' not found > > I modified my model to look like this and deleted my old indexes and > ran "rake ts:index" again to make sure i had a clean start: > > define_index do > indexes [:name, iso_alpha_2], :as => :country > indexes capital > has '4', :as => :class_sort, :type => :integer > end > > My search query is like: > @search_results = ThinkingSphinx.search query, :page => > params[:page], :per_page => 30, :order => :class_sort > > I also tried the other variation of ordering on class_sort as well and > had the same error. > > Am I doing something wrong there? > On Aug 11, 7:52 am, Pat Allan <[email protected]> wrote: >> No worries :) >> >> -- >> Pat >> >> On 11/08/2011, at 9:59 PM, mikeee wrote: >> >> >> >> >> >> >> >>> Thanks Pat - this is perfect. >> >>> Thanks also for maintaining TS - it's fantastic. >> >>> Mike >> >>> On Aug 11, 2:17 am, Pat Allan <[email protected]> wrote: >>>> Hi Mike >> >>>> There's a couple of options - firstly, you can weight certain indices to >>>> have higher priorities in your search call: >> >>>> :index_weights => {Continent => 4, Country => 3, StateProvince => 2, >>>> Place => 1} >> >>>> That won't ensure your order, though - if a country is a far better match >>>> than a low continent, then it'll probably end up above it. Could play with >>>> those numbers (any indices/classes not mentioned get a weight of 1), they >>>> don't need to be sequential, could be anything. >> >>>> A more reliable option, if the ordering is critical, is give each model a >>>> manual attribute like so - changing the number each time to ensure your >>>> sort order: >> >>>> has '1', :as => :class_sort, :type => :integer >> >>>> And then use :order => :class_sort - or, better: "class_sort ASC, >>>> @relevance DESC" >> >>>> Cheers >> >>>> -- >>>> Pat >> >>>> On 11/08/2011, at 1:14 PM, mikeee wrote: >> >>>>> Hi - >> >>>>> I have a few models I'm indexing: Continent, Country, StateProvince >>>>> and Place >> >>>>> I'd like if possible to have the ranking/weight of these to be in the >>>>> order I've listed above in the search results. Is there any way to >>>>> do this? >> >>>>> I've tried using the :classes attribute but that doesn't seem to >>>>> affect the ranking. >> >>>>> Thanks for any advice. >> >>>>> Mike >> >>>>> -- >>>>> 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 >>> 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.
