What about in your controller?
--
Pat
On 05/11/2010, at 5:01 PM, Victor wrote:
> When I performed a search, the following 500 occured:
>
> Processing TripsController#index (for 115.164.60.198 at 2010-11-05
> 13:50:19) [GET]
> Parameters: {"country"=>"All", "days"=>"", "action"=>"index",
> "filter"=>"on", "order"=>"date_descend", "controller"=>"trips",
> "keyword"=>"mid valley"}
>
> NameError (undefined local variable or method `options' for
> #<TripsController:0xb693d44>):
>
> I did not have any variable "options" anywhere in my trip.rb, or
> Trip's index.html.erb.
>
> On Nov 4, 9:37 pm, Victor <[email protected]> wrote:
>> Sorry Pat, we posted at the same time. Will get back to you when I
>> have tried that. Thanks.
>>
>> On Nov 4, 9:29 pm, Victor <[email protected]> wrote:
>>
>>> Hi Pat,
>>
>>> I am sorry that I may need step-by-step guide here.
>>
>>> Ok, I have added "has trip_id" in the TripDay model.
>>
>>> Next is the trips_controller.rb. If you see my code above, I have also
>>> added ":group_by => trip_id" and ":group_function => :attr" to the
>>> Trip.search.
>>
>>> The filter form is in my Trips' index.html.erb. I notice that I
>>> haven't really included the Trip.search to search TripDay as well
>>> because when I search, it still returns zero result. How should I add
>>> that?
>>
>>> Thanks for your help. Really appreciate it.
>>
>>> On Nov 4, 9:17 pm, Pat Allan <[email protected]> wrote:
>>
>>>> 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
>>
>> ...
>>
>> 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.