No worries about being a noob - we've all got to start somewhere :) Yes, you need to add 'has trip_id' to the define_index block in your TripDay model - if the attribute doesn't exist, you won't be able to group by it.
Cheers -- Pat On 03/11/2010, at 7:11 PM, Victor wrote: > Hi Pat > > Here are the models so far: > > trip_day.rb > ========= > class TripDay < ActiveRecord::Base > belongs_to :trip > > has_many :trip_day_spots > has_many :spots, :through => :trip_day_spots > > # ThinkingSphinx Index > define_index do > indexes spots.name, :as => :spot_name > indexes spots.city, :as => :spot_city > indexes spots.state, :as => :spot_state > indexes spots.country, :as => :spot_country > end > end > > > Trip.rb > ======= > class Trip < ActiveRecord::Base > belongs_to :user, :counter_cache => true > > has_many :spot_trips, :dependent => :destroy > has_many :spots, :through => :spot_trips > > has_many :trip_days, :dependent => :destroy > has_many :trip_reviews, :dependent => :destroy > > # ThinkingSphinx Index > define_index do > indexes :name, :sortable => true > indexes duration > has budget, created_at, rating_average > end > end > > > trip_day already belongs to Trip. Must I put in "has trip_id" in > trip_day.rb? > > Sorry for being a noob here. > > Thanks. > > On Nov 3, 2:43 pm, Pat Allan <[email protected]> wrote: >> Hi Victor >> >> Well, it's great that it works here. >> >> 1. You are indeed right, you're indexing columns from the spots association >> as fields. >> 2. You could add an attribute of trip_id to TripDay's index: >> has trip_id >> And then group the results by >> trip_id...http://freelancing-god.github.com/ts/en/searching.html#grouping >> >> That said, it *should* work for Trip. Perhaps try stopping Sphinx, deleting >> the index files, and then run rake ts:rebuild to generate it all from >> scratch for sure? >> >> -- >> Pat >> >> On 03/11/2010, at 4:55 PM, Victor wrote: >> >>> Hi Pat, >> >>> I have added indexes to the following >> >>> trip_day.rb >>> ======== >>> class TripDay < ActiveRecord::Base >>> belongs_to :trip >> >>> has_many :trip_day_spots >>> has_many :spots, :through => :trip_day_spots >> >>> # ThinkingSphinx Index >>> define_index do >>> indexes spots.name, :as => :spot_name >>> indexes spots.city, :as => :spot_city >>> indexes spots.state, :as => :spot_state >>> indexes spots.country, :as => :spot_country >>> end >>> . >>> . >>> . >>> end >> >>> I ran ts:rebuild, then search this in console: >> >>>>> TripDay.search "Cititel Mid Valley" >>> => [#<TripDay id: 4, trip_date: "2010-10-06", trip_id: 2, created_at: >>> "2010-10-21 10:17:18", updated_at: "2010-10-21 10:17:18">] >> >>> Few questions: >> >>> 1. Previously, was the trip.rb indexing the spots name, city, country, >>> etc. correctly? They are indexed, am I right? >>> 2. With the TripDay now can be indexed, is there anyway for me to use >>> it as search for my Trips? >> >>> Thanks. >> >>> On Nov 2, 11:59 am, Pat Allan <[email protected]> wrote: >>>> Of course - though I would prefer a donation once the problem's solved >>>> ;)http://pledgie.com/campaigns/1752 >> >>>> -- >>>> Pat >> >>>> On 02/11/2010, at 2:43 PM, Victor wrote: >> >>>>> No problem Pat. Can I have a link to make donation? :) >> >>>>> On Nov 2, 8:06 am, Pat Allan <[email protected]> wrote: >>>>>> Sorry Victor, I'm out of ideas as to what's causing the problem, beyond >>>>>> investigating it on the server myself (and even then, I couldn't promise >>>>>> anything). >> >>>>>> -- >>>>>> Pat >> >>>>>> On 01/11/2010, at 11:33 PM, Victor wrote: >> >>>>>>> So when I did the Trip.searc: >> >>>>>>>>> Trip.search "Inna Putri Bali" >> >>>>>>> => [] >> >>>>>>> Spots in Trip is not indexed? >> >>>>>>> I don't have any sphinx scopes. >> >>>>>>> On Nov 1, 8:29 pm, Pat Allan <[email protected]> wrote: >>>>>>>> But you're running these commands via console - so we're avoiding the >>>>>>>> controllers and views, and it's still not working... >> >>>>>>>> -- >>>>>>>> Pat >> >>>>>>>> On 01/11/2010, at 9:27 PM, Victor wrote: >> >>>>>>>>> Could it be that my filter in view or controller wasn't setup properly >>>>>>>>> to search the right place? >> >>>>>>>>> On Nov 1, 6:21 pm, Pat Allan <[email protected]> wrote: >>>>>>>>>> I live in Melbourne, and I've not been to the Gaol yet ;) >> >>>>>>>>>> I'm running out of ideas at the moment... the SQL looks correct, the >>>>>>>>>> data's being indexed, and searchd is restarting as expected. You >>>>>>>>>> don't have any sphinx scopes (or more importantly - a default sphinx >>>>>>>>>> scope) in the Trip model, do you? >> >>>>>>>>>> -- >>>>>>>>>> Pat >> >>>>>>>>>> On 01/11/2010, at 9:13 PM, Victor wrote: >> >>>>>>>>>>> If I did "Spot.search "Inna Putri Bali" >> >>>>>>>>>>>>> Spot.search "Inna Putri Bali" >>>>>>>>>>> => [#<Spot id: 2, spot_type: "accommodation", name: "Inna Putri >>>>>>>>>>> Bali", >>>>>>>>>>> acc_type: "Hotel", operation_hours: "", check_in: "2000-01-01 >>>>>>>>>>> 14:00:00", check_out: "2000-01-01 13:00:00", season: "No season", >>>>>>>>>>> prices: "Check their website for latest deals. It's much che...", >>>>>>>>>>> country: "Indonesia", zip: "80363", state: "Bali", city: "Kuta", >>>>>>>>>>> address: "Jalan Kawasan Nusa Dua Resort", contact: "+62 361771020", >>>>>>>>>>> email: "[email protected]", web: "http://hotelputribali.com", >>>>>>>>>>> description: "Inna Putri Bali is set on a wide of Nusa Dua. The >>>>>>>>>>> e...", >>>>>>>>>>> reviews_count: 0, rating_average: #<BigDecimal:b65d3ffc,'0.0',4(8)>, >>>>>>>>>>> lat: #<BigDecimal:b65d3fac,'-0.8799857E1',12(16)>, lng: >>>>>>>>>>> #<BigDecimal:b65d3ee4,'0.115228862E3',12(20)>, created_at: >>>>>>>>>>> "2010-10-20 >>>>>>>>>>> 04:12:17", updated_at: "2010-11-01 09:04:36", photos_count: 13>] >> >>>>>>>>>>> On Nov 1, 5:48 pm, Victor <[email protected]> wrote: >>>>>>>>>>>> Trying "Inna Putri Bali" instead >> >>>>>>>>>>>> Loading production environment (Rails 2.3.8) >>>>>>>>>>>> ** Erubis 2.6.6>> Trip.search "Inna Putri Bali" >> >>>>>>>>>>>> => [] >> >>>>>>>>>>>> Looks like we have a problem here huh... >> >>>>>>>>>>>> By the way, Old Melbourne Gaol was awesome. Went there once. >> >>>>>>>>>>>> On Nov 1, 5:41 pm, Pat Allan <[email protected]> wrote: >> >>>>>>>>>>>>> Right, that seems fine, so now let's look back within the Rails >>>>>>>>>>>>> app. On the server, in 'script/console production', what's the >>>>>>>>>>>>> output of the following: >>>>>>>>>>>>> Trip.search "Old Melbourne Gaol" >> >>>>>>>>>>>>> -- >>>>>>>>>>>>> Pat >> >>>>>>>>>>>>> On 01/11/2010, at 8:37 PM, Victor wrote: >> >>>>>>>>>>>>>> So I run 'ps aux | grep searchd' >> >>>>>>>>>>>>>> 1000 17569 0.0 0.2 9168 1144 ? S 04:00 0:00 >>>>>>>>>>>>>> searchd --pidfile --config /var/www/abc.com/public/abc/releases/ >>>>>>>>>>>>>> 20101008073517/config/production.sphinx.conf >>>>>>>>>>>>>> 1000 20220 0.0 0.1 1864 700 pts/0 S+ 17:34 0:00 >>>>>>>>>>>>>> grep >>>>>>>>>>>>>> --color=auto searchd >> >>>>>>>>>>>>>> Then 'rake ts:rebuild RAILS_ENV=production' >> >>>>>>>>>>>>>> ** Erubis 2.6.6 >>>>>>>>>>>>>> Stopped search daemon (pid 17569). >>>>>>>>>>>>>> Generating Configuration to /var/www/abc.com/public/abc/releases/ >>>>>>>>>>>>>> 20101008073517/config/production.sphinx.conf >>>>>>>>>>>>>> Sphinx 1.10-beta (r2420) >>>>>>>>>>>>>> Copyright (c) 2001-2010, Andrew Aksyonoff >>>>>>>>>>>>>> Copyright (c) 2008-2010, Sphinx Technologies Inc (http:// >>>>>>>>>>>>>> sphinxsearch.com) >> >>>>>>>>>>>>>> using config file >>>>>>>>>>>>>> '/var/www/abc.com/public/abc/releases/20101008073517/ >>>>>>>>>>>>>> config/production.sphinx.conf'... >>>>>>>>>>>>>> indexing index 'spot_core'... >>>>>>>>>>>>>> collected 7 docs, 0.0 MB >>>>>>>>>>>>>> sorted 0.0 Mhits, 100.0% done >>>>>>>>>>>>>> total 7 docs, 5351 bytes >>>>>>>>>>>>>> total 0.015 sec, 343828 bytes/sec, 449.78 docs/sec >>>>>>>>>>>>>> skipping non-plain index 'spot'... >>>>>>>>>>>>>> indexing index 'trip_core'... >>>>>>>>>>>>>> collected 3 docs, 0.0 MB >>>>>>>>>>>>>> sorted 0.0 Mhits, 100.0% done >>>>>>>>>>>>>> total 3 docs, 55 bytes >>>>>>>>>>>>>> total 0.004 sec, 13372 bytes/sec, 729.39 docs/sec >>>>>>>>>>>>>> skipping non-plain index 'trip'... >>>>>>>>>>>>>> total 12 reads, 0.000 sec, 8.1 kb/call avg, 0.0 msec/call avg >>>>>>>>>>>>>> total 24 writes, 0.000 sec, 9.0 kb/call avg, 0.0 msec/call avg >>>>>>>>>>>>>> Started successfully (pid 20236). >> >>>>>>>>>>>>>> Then 'ps aux | grep searchd' >> >>>>>>>>>>>>>> 1000 20236 0.0 0.1 9164 780 pts/0 S 17:35 0:00 >>>>>>>>>>>>>> searchd --pidfile --config /var/www/abc.com/public/abc/releases/ >>>>>>>>>>>>>> 20101008073517/config/production.sphinx.conf >>>>>>>>>>>>>> 1000 20238 0.0 0.1 1860 596 pts/0 S+ 17:37 0:00 >>>>>>>>>>>>>> grep >>>>>>>>>>>>>> --color=auto searchd >> >>>>>>>>>>>>>> On Nov 1, 5:32 pm, Pat Allan <[email protected]> wrote: >>>>>>>>>>>>>>> Hi Victor >> >>>>>>>>>>>>>>> That seems fine... >>>>>>>>>>>>>>> What is the output of 'ps aux | grep searchd' before *and* >>>>>>>>>>>>>>> after running 'rake ts:rebuild'? >> >>>>>>>>>>>>>>> I want to make sure we're dealing with just a single searchd >>>>>>>>>>>>>>> instance that is noting the changes. >> >>>>>>>>>>>>>>> Cheers >> >>>>>>>>>>>>>>> -- >>>>>>>>>>>>>>> Pat >> >>>>>>>>>>>>>>> On 01/11/2010, at 8:24 PM, Victor wrote: >> >>>>>>>>>>>>>>>> Here it is in my production.sphinx.conf instead. >> >>>>>>>>>>>>>>>> indexer >>>>>>>>>>>>>>>> { >>>>>>>>>>>>>>>> } >> >>>>>>>>>>>>>>>> searchd >>>>>>>>>>>>>>>> { >>>>>>>>>>>>>>>> listen = 127.0.0.1:9791 >>>>>>>>>>>>>>>> log = /var/www/abc.com/public/abc/releases/20101008073517/log/ >>>>>>>>>>>>>>>> searchd.log >>>>>>>>>>>>>>>> query_log = >>>>>>>>>>>>>>>> /var/www/abc.com/public/abc/releases/20101008073517/log/ >>>>>>>>>>>>>>>> searchd.query.log >>>>>>>>>>>>>>>> pid_file = >>>>>>>>>>>>>>>> /var/www/abc.com/public/abc/releases/20101008073517/log/ >>>>>>>>>>>>>>>> searchd.production.pid >>>>>>>>>>>>>>>> } >> >>>>>>>>>>>>>>>> source spot_core_0 >>>>>>>>>>>>>>>> { >>>>>>>>>>>>>>>> type = mysql >>>>>>>>>>>>>>>> sql_host = localhost >>>>>>>>>>>>>>>> sql_user = root >>>>>>>>>>>>>>>> sql_pass = >>>>>>>>>>>>>>>> sql_db = abc_production >>>>>>>>>>>>>>>> sql_query_pre = SET NAMES utf8 >>>>>>>>>>>>>>>> sql_query_pre = SET TIME_ZONE = '+0:00' >>>>>>>>>>>>>>>> sql_query = SELECT SQL_NO_CACHE `spots`.`id` * 2 + 0 AS `id` , >>>>>>>>>>>>>>>> `spots`.`name` AS `name`, `spots`.`address` AS `address`, >>>>>>>>>>>>>>>> `spots`.`city` AS `city`, `spots`.`state` AS `state`, >>>>>>>>>>>>>>>> `spots`.`country` AS `country`, `spots`.`spot_type` AS >>>>>>>>>>>>>>>> `spot_type`, >>>>>>>>>>>>>>>> `spots`.`description` AS `description`, `spots`.`id` AS >>>>>>>>>>>>>>>> `sphinx_internal_id`, 419485005 AS `class_crc`, 0 AS >>>>>>>>>>>>>>>> `sphinx_deleted`, >>>>>>>>>>>>>>>> IFNULL(`spots`.`name`, '') AS `name_sort`, >>>>>>>>>>>>>>>> `spots`.`rating_average` AS >>>>>>>>>>>>>>>> `rating_average` FROM `spots` WHERE `spots`.`id` >= $start >>>>>>>>>>>>>>>> AND >>>>>>>>>>>>>>>> `spots`.`id` <= $end GROUP BY `spots`.`id` ORDER BY NULL >>>>>>>>>>>>>>>> sql_query_range = SELECT IFNULL(MIN(`id`), 1), >>>>>>>>>>>>>>>> IFNULL(MAX(`id`), 1) >>>>>>>>>>>>>>>> FROM `spots` >>>>>>>>>>>>>>>> sql_attr_uint = sphinx_internal_id >>>>>>>>>>>>>>>> sql_attr_uint = class_crc >>>>>>>>>>>>>>>> sql_attr_uint = sphinx_deleted >>>>>>>>>>>>>>>> sql_attr_str2ordinal = name_sort >>>>>>>>>>>>>>>> sql_attr_float = rating_average >>>>>>>>>>>>>>>> sql_query_info = SELECT * FROM `spots` WHERE `id` = (($id - >>>>>>>>>>>>>>>> 0) / 2) >>>>>>>>>>>>>>>> } >> >>>>>>>>>>>>>>>> index spot_core >>>>>>>>>>>>>>>> { >>>>>>>>>>>>>>>> source = spot_core_0 >>>>>>>>>>>>>>>> path = /var/www/abc.com/public/abc/shared/db/sphinx/spot_core >>>>>>>>>>>>>>>> charset_type = utf-8 >>>>>>>>>>>>>>>> min_infix_len = 3 >>>>>>>>>>>>>>>> enable_star = 1 >>>>>>>>>>>>>>>> } >> >>>>>>>>>>>>>>>> index spot >>>>>>>>>>>>>>>> { >>>>>>>>>>>>>>>> type = distributed >>>>>>>>>>>>>>>> local = >> >> ... >> >> read more ยป > > -- > 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.
