Hey Pat,
Yes, I ran rebuild.
BTW, I added the index :
*indexes user.couple_detail.fname, :as =: :first_name*
and it works fine.
My search in ratings_controller is like this.
*@ratings = Rating.search :conditions => {:associated_id =>
params[:vendor_id], :email => params[:email],*
* :business_name =>
params[:business_name], :first_name => params[:first_name]},*
* :order => "updated_at DESC", :page =>
params[:page], :per_page => 2, :star => true*
Searching with Business Name always returns empty.
The generated query looks like this:
*Sphinx Query (0.7ms) SELECT * FROM `rating_core` WHERE
MATCH('@business_name *Great* *Photography*') AND `sphinx_deleted` = 0
ORDER BY `updated_at` DESC LIMIT 0, 20*
* Sphinx Found 0 results*
The only clue i get, is a message (not all the time) on the console after
running the search query saying:
Creating scope :user_ratings_for_type_and_id.
Overwriting existing method Rating.user_ratings_for_type_and_id.
I commented out all the scopes, but still no luck. But Im thinking there is
where the problem lies.
Have you run into anything like this?
Thank you
On Wed, Apr 2, 2014 at 2:40 PM, Pat Allan <[email protected]> wrote:
> Have you run `rake ts:rebuild` since adding that field to your index
> definition? Can you provide an example of the search you're running, and
> the result you're expecting to see?
>
> On 3 Apr 2014, at 3:34 am, Fernanda Aispuro <[email protected]>
> wrote:
>
> Yes there is.
> But my result set is always empty. The same happens with other
> associations like user.couple_detail.fname.
>
> Any suggestions as to how what to try?
> Thanks Pat
>
>
> On Tue, Apr 1, 2014 at 4:29 PM, Pat Allan <[email protected]>wrote:
>
>> Hi Fernanda
>>
>> It looks like you have the association names correct for the field - is
>> there a database column called business_name in the vendor_details table?
>>
>> --
>> Pat
>>
>> On 2 Apr 2014, at 9:22 am, Fernanda Aispuro <[email protected]>
>> wrote:
>>
>> First time using TS.
>> I've seen questions about drilling down on associations for indexing, but
>> not what I need.
>>
>> This are my models:
>>
>> *Rating.rb*
>> *belongs_to :associated, polymorphic=> true*
>> *belongs_to :user*
>> *#associated is a user that has_one :vendor_detail*
>> *#user will be user that has_one :couple_detail*
>>
>> *User.rb*
>> *has_one :vendor_detail*
>> *has_one :couple_detail*
>> *has_many :ratings, as: :associated*
>>
>>
>> *ThinkingSphinx::Index.define :rating, :with => :active_record do*
>> * indexes associated_id*
>> * indexes user.email, :as => :email*
>> * indexes user.vendor_detail.business_name, :as => :business_name*
>> * has user_id, updated_at*
>> *end*
>>
>>
>> associated_id and user.email return the expected results.
>> However, ser.vendor_detail.business_name returns empty. I tried adding
>> the line 'join user.vendor_detail', but nothing changes.
>>
>> My development.sphinx.config says:
>> source rating_core_0
>> {
>> type = mysql
>> sql_host = localhost
>> sql_user = root
>> sql_pass =
>> sql_db = weddingful_dev
>> sql_query_pre = SET TIME_ZONE = '+0:00'
>> sql_query_pre = SET NAMES utf8
>> sql_query = SELECT SQL_NO_CACHE `ratings`.`id` * 12 + 3 AS `id`,
>> 'Rating' AS `sphinx_internal_class_name`, `ratings`.`associated_id` AS
>> `associated_id`, users.`email` AS `email`, `ratings`.`id` AS
>> `sphinx_internal_id`, 'Rating' AS `sphinx_internal_class`, 0 AS
>> `sphinx_deleted`, couple_detail.`fname` AS `first_name`,
>> `ratings`.`user_id` AS `user_id`, UNIX_TIMESTAMP(`ratings`.`updated_at`)
>> AS `updated_at` FROM `ratings` LEFT OUTER JOIN `users` ON `users`.`id` =
>> `ratings`.`user_id` LEFT OUTER JOIN `couple_detail` ON
>> `couple_detail`.`user_id` = `users`.`id` WHERE (`ratings`.`id` BETWEEN
>> $start AND $end) GROUP BY `ratings`.`id`, `ratings`.`associated_id`,
>> users.`email`, `ratings`.`id`, couple_detail.`fname`, `ratings`.`user_id`,
>> `ratings`.`updated_at` ORDER BY NULL
>> sql_query_range = SELECT IFNULL(MIN(`ratings`.`id`), 1),
>> IFNULL(MAX(`ratings`.`id`), 1) FROM `ratings`
>> sql_attr_uint = sphinx_internal_id
>> sql_attr_uint = sphinx_deleted
>> sql_attr_uint = user_id
>> sql_attr_timestamp = updated_at
>> sql_attr_string = sphinx_internal_class
>> sql_attr_string = first_name
>> sql_query_info = SELECT `ratings`.* FROM `ratings` WHERE
>> (`ratings`.`id` = ($id - 3) / 12)
>> }
>>
>> Any ideas what I'm doing wrong?
>> Thanks!
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Thinking Sphinx" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at http://groups.google.com/group/thinking-sphinx.
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Thinking Sphinx" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at http://groups.google.com/group/thinking-sphinx.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Thinking Sphinx" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/thinking-sphinx.
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Thinking Sphinx" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/thinking-sphinx.
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"Thinking Sphinx" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/thinking-sphinx.
For more options, visit https://groups.google.com/d/optout.