Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Indexing an instance method data

Received: by 10.101.146.6 with SMTP id y6mr7257320ann.56.1281082744997;
        Fri, 06 Aug 2010 01:19:04 -0700 (PDT)
X-BeenThere: thinking-sphinx@googlegroups.com
Received: by 10.101.156.10 with SMTP id i10ls1195430ano.3.p; Fri, 06 Aug 2010 
	01:19:02 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.101.179.22 with SMTP id g22mr1440057anp.46.1281082742189; Fri, 
	06 Aug 2010 01:19:02 -0700 (PDT)
Received: by o7g2000prg.googlegroups.com with HTTP; Fri, 6 Aug 2010 01:19:02 
	-0700 (PDT)
Date: Fri, 6 Aug 2010 01:19:02 -0700 (PDT)
In-Reply-To: <AANLkTimHM-o0tFQCiqhs3-9Xa4C4cOpQYOWSVtvv4w_E@mail.gmail.com>
X-IP: 122.170.56.198
References: <60ca5846-b1ff-40fd-ba5c-cb377340c583@w15g2000pro.googlegroups.com> 
	<20100805063821.GS8971@deefa.com> <cf2ddb68-cd16-438a-a615-7dd561933578@p11g2000prf.googlegroups.com> 
	<14514E95-F8C3-49BC-8E23-0249CFDBB03C@freelancing-gods.com> 
	<6d5aaa4e-b409-4de1-aa29-63eaea137cb0@g6g2000pro.googlegroups.com> 
	<AANLkTimHM-o0tFQCiqhs3-9Xa4C4cOpQYOWSVtvv4w_E@mail.gmail.com>
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.4) 
	Gecko/20091027 Fedora/3.5.4-1.fc12 Firefox/3.5.4,gzip(gfe)
Message-ID: <f709b3ce-1117-4984-9795-26579304b887@o7g2000prg.googlegroups.com>
Subject: Re: Indexing an instance method data
From: Mike Disuza <mikyd...@gmail.com>
To: Thinking Sphinx <thinking-sphinx@googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Thanks Guys For your reply.
I got the answer.

On Aug 6, 1:03=A0pm, Jim Ruther Nill <jvn...@gmail.com> wrote:
> Hi Mike,
>
> Yes. You have to add the ratings column in your database. =A0But since yo=
u are
> using the plugin which adds a 'rating' method for your model, you need to
> have a different column name for your database, hence Pat and James
> suggested the name to be 'cached_rating'. =A0The reason behind this is
> TS/Sphinx only deals with columns that are actually in your database. =A0=
So
> any method in your model can't be used.
>
> =A0 =A01. create a migration to add the cached_rating column to your tabl=
e
> =A0 =A02. add the before_validation callback and necessary methods (as co=
ded by
> =A0 =A0Pat) to set the cached_rating value and save it in the database.
> =A0 =A03. rebuild your index
> =A0 =A04. happy searching :D
>
>
>
> On Fri, Aug 6, 2010 at 3:42 PM, Mike Disuza <mikyd...@gmail.com> wrote:
> > Hi
> > I am confused, Are you saying that I have to add the "cached_rating"
> > column in my table? If yes then it is better I will store the "rating"
> > value by creating a new column in the table. So that i will not be
> > having this headche.
>
> > Thanks,
> > Mike
>
> > On Aug 6, 11:44 am, Pat Allan <p...@freelancing-gods.com> wrote:
> > > Hi Mike
>
> > > I think it's before_validation... and you'd probably want something m=
ore
> > like:
>
> > > =A0 before_validation :set_cached_rating
>
> > > =A0 def set_cached_rating
> > > =A0 =A0 self.cached_rating =3D rating
> > > =A0 end
>
> > > This way the value is actually being stored in the database :)
>
> > > --
> > > Pat
>
> > > On 06/08/2010, at 4:39 PM, Mike Disuza wrote:
>
> > > > Hi,
> > > > I am trying your solution like this
> > > > My model is like this:-
> > > > "
> > > > before_validate :cache_rating
> > > > define_index do
> > > > =A0 =A0indexes :name,:sortable =3D> true
> > > > =A0 =A0indexes cached_rating, :as=3D>:property_rating
> > > > end
> > > > def cache_rating
> > > > =A0 =A0self.rating
> > > > end
> > > > "
> > > > Whenever I am trying to rebuild the indexing using "rake ts:rebuild=
",
> > > > I am getting error "undefined method `before_validate' for #<Class:
> > > > 0xb6cce9c4>"
>
> > > > Can anyone help me out.
>
> > > > Thanks,
> > > > Mike
>
> > > > On Aug 5, 11:38 am, James Healy <ji...@deefa.com> wrote:
> > > >> Mike Disuza wrote:
> > > >>> For rating I am using "acts_as_a_rateable" plugin which is giving=
 a
> > > >>> rating by using "obj.rating" method.
> > > >>> I know that Sphinx does not do indexing of the method.
>
> > > >>> Can anyone have any idea how to solve this?
>
> > > >> I'm not familiar with the acts_as_a_rateable plugin, but you proba=
bly
> > > >> have 2 options:
>
> > > >> * find out if the plugin stores the rating in your database somewh=
ere
> > > >> =A0 and add that column to your index
>
> > > >> * if the rating is purely calculated in ruby, you will have to add=
 a
> > > >> =A0 model callback that caches the value in your database. I've
> > described
> > > >> =A0 this technique a few times on stack overflow, check out [1]
>
> > > >> -- James Healy <ji...@deefa.com> =A0Thu, 05 Aug 2010 16:37:45 +100=
0
>
> > > >> [1]
> >http://stackoverflow.com/questions/3391048/including-rails-activereco...
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > Groups "Thinking Sphinx" group.
> > > > To post to this group, send email to thinking-sph...@googlegroups.c=
om.
> > > > To unsubscribe from this group, send email to
> > thinking-sphinx+unsubscribe@googlegroups.com<thinking-sphinx%2Bunsubscr=
ibe@googlegroups.com>
> > .
> > > > For more options, visit this group athttp://
> > groups.google.com/group/thinking-sphinx?hl=3Den.
>
> > --
> > You received this message because you are subscribed to the Google Grou=
ps
> > "Thinking Sphinx" group.
> > To post to this group, send email to thinking-sphinx@googlegroups.com.
> > To unsubscribe from this group, send email to
> > thinking-sphinx+unsubscribe@googlegroups.com<thinking-sphinx%2Bunsubscr=
ibe@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/thinking-sphinx?hl=3Den.
>
> --
> -------------------------------------------------------------