Hi Pat,
I have tried both the options, but no luck. My trace log is as
foolows:-
1) Property.search 'this', :order=> :name
/usr/local/ruby/lib/ruby/gems/1.8/gems/browsercms-3.1.0/lib/cms/
behaviors/searching.rb:17: warning: multiple values for a block
parameter (2 for 1)
from /usr/local/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/
active_record/named_scope.rb:92
=> []
>> ThinkingSphinx.search 'this', :order=> :name
=> []
2) Property.search 'this', :order => :the_name
/usr/local/ruby/lib/ruby/gems/1.8/gems/browsercms-3.1.0/lib/cms/
behaviors/searching.rb:17: warning: multiple values for a block
parameter (2 for 1)
from /usr/local/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/
active_record/named_scope.rb:92
=> []
>> ThinkingSphinx.search 'this', :order => :the_name
=> []
Also, if you see I am getting an error whenever I doing
"Property.search 'this', :order=> :name".
One more thing I am integrating the Sphinx/Thinking-Sphinx in Browser
CMS application. Will it be causing an issue?
Thanks,
Mike
On Aug 10, 9:37 am, Pat Allan <[email protected]> wrote:
> Hi Mike
>
> Firstly, I'm going to start with the obvious, just to make sure - apologies
> if you've done this already.
>
> 1. Change your define_index block to the following:
>
> define_index do
> indexes :name, :sortable => true
> indexes description
> indexes rate,:sortable => true
> indexes neighbourhoods.name, :as=>:neighbourhood
> where 'properties.deleted = 0'
> has exclusive
> has published
> has created_at, updated_at
> end
>
> 2. Run rake ts:rebuild
> 3. Try the following in script/console: Property.search '', :order => :name
>
> If that doesn't work, then here's something else to try:
>
> 1. Slightly different define_index block:
>
> define_index do
> indexes :name, :as => :the_name, :sortable => true
> indexes description
> indexes rate,:sortable => true
> indexes neighbourhoods.name, :as=>:neighbourhood
> where 'properties.deleted = 0'
> has exclusive
> has published
> has created_at, updated_at
> end
>
> 2. Again, rake ts:rebuild
> 3. In script/console: Property.search '', :order => :the_name
>
> If that doesn't work either, let me know, because it sounds like a bug to me.
>
> --
> Pat
>
> On 09/08/2010, at 8:10 PM, Mike Disuza wrote:
>
> > Hi Pat,
> > If I am not duplicating the field and attribute for sorting then it is
> > not working.
> > What is issue? I am not able to understand.
>
> > Thanks,
> > Mike
>
> > On Aug 7, 6:48 am, Pat Allan <[email protected]> wrote:
> >> Hi Mike
>
> >> That post is for float values, not strings... you really shouldn't need to
> >> double-up with a field *and* attribute. :sortable => true on the field
> >> should be all that's required. Still, at least it's working now.
>
> >> --
> >> Pat
>
> >> On 06/08/2010, at 11:26 PM, Mike Disuza wrote:
>
> >>> Hi Pat,
> >>> I have read the post
> >>>http://stackoverflow.com/questions/879267/searching-and-sorting-by-a-...
>
> >>> which says that if you want to sort the field then only sortable=>true
> >>> will not sort the data but you have to add it in attributes as well, I
> >>> don't know why it is required.
> >>> So I have modified my indexes like that and it is working perfectly.
>
> >>> define_index do
> >>> indexes :name, :as=> "pname", :sortable => true
> >>> indexes description
> >>> indexes rate,:sortable => true
> >>> indexes neighbourhoods.name, :as=>:neighbourhood
> >>> where 'properties.deleted = 0'
> >>> has exclusive
> >>> has published, :name
> >>> has created_at, updated_at
> >>> end
>
> >>> Thanks,
> >>> Mike
>
> >>> On Aug 6, 6:15 pm, Pat Allan <[email protected]> wrote:
> >>>> That'll teach me for being so sure I had the answer ;)
>
> >>>> Have you reindexed and restarted Sphinx since adding :sortable to the
> >>>> field?
>
> >>>> --
> >>>> Pat
>
> >>>> On 06/08/2010, at 10:58 PM, Mike Disuza <[email protected]> wrote:
>
> >>>>> Hi Pat,
> >>>>> I already tried this. Not working
> >>>>> "ThinkingSphinx.search "this", :order=> :name"
> >>>>> This is whole model(property.rb) fields which I have indexed.
>
> >>>>> define_index do
> >>>>> indexes :name,:sortable => true
> >>>>> indexes description
> >>>>> indexes rate,:sortable => true
> >>>>> indexes neighbourhoods.name, :as=>:neighbourhood
> >>>>> where 'properties.deleted = 0'
> >>>>> has exclusive
> >>>>> has published
> >>>>> has created_at, updated_at
> >>>>> end
> >>>>> Is there any wrong in this?
>
> >>>>> Thanks,
> >>>>> Mike
>
> >>>>> On Aug 6, 5:53 pm, Pat Allan <[email protected]> wrote:
> >>>>>> Hi Mike
>
> >>>>>> When you're sorting, use :name, not "name" - if you're using a
> >>>>>> string, then Thinking Sphinx behaves a different way (using the
> >>>>>> extended sort mode, instead of attribute asc/desc sort mode).
>
> >>>>>> So, using a symbol should take care of it all.
>
> >>>>>> Cheers
>
> >>>>>> --
> >>>>>> Pat
>
> >>>>>> On 06/08/2010, at 10:12 PM, Mike Disuza wrote:
>
> >>>>>>> Hi,
> >>>>>>> No I have only property model and which have these fields to index.
> >>>>>>> Thanks,
> >>>>>>> Mike
>
> >>>>>>> On Aug 6, 4:43 pm, Jim Ruther Nill <[email protected]> wrote:
> >>>>>>>> do you any other indexed models?
>
> >>>>>>>> On Fri, Aug 6, 2010 at 7:36 PM, Mike Disuza <[email protected]>
> >>>>>>>> wrote:
> >>>>>>>>> Hi,
> >>>>>>>>> I have indexing as follows
> >>>>>>>>> "define_index do
> >>>>>>>>> indexes :name,:sortable => true
> >>>>>>>>> indexes description
> >>>>>>>>> has created_at, updated_at
> >>>>>>>>> end"
>
> >>>>>>>>> Whenever I am doing search like
> >>>>>>>>> " ThinkingSphinx.search "this" ". I am getting search result but
> >>>>>>>>> whenever I am doing sorting with name like
> >>>>>>>>> " ThinkingSphinx.search "this", :order =>
> >>>>>>>>> "name",:sort_mode=>:desc " I
> >>>>>>>>> am not getting any search result. It returns a blank array.
>
> >>>>>>>>> Can anyone tell me what is wrong with my code?
>
> >>>>>>>>> Thanks,
> >>>>>>>>> Tushar
>
> >>>>>>>>> --
> >>>>>>>>> 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]<thinking-sphinx
> >>>>>>>>> %[email protected]>
> >>>>>>>>> .
> >>>>>>>>> For more options, visit this group at
> >>>>>>>>>http://groups.google.com/group/thinking-sphinx?hl=en.
>
> >>>>>>>> --
> >>>>>>>> -------------------------------------------------------------
> >>>>>>>> visit my blog athttp://jimlabs.heroku.com
>
> >>>>>>> --
> >>>>>>> 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
> >>> 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.