FYI, Some of this stuff looks a tad bit strange as I am in the process of rewriting a 1.2 Rails app and replacing Ferret for the search engine. So, I've been jumping through a few hoops maintaining limited backward compatibility in places - stuff like :limit, for example, which gets translated to per_page in the model before the call.
On Jul 30, 9:09 am, Andrew Lippert <[email protected]> wrote: > I removed the set_properties for lat/lng with no change. I had high > hopes it was something really strange related to your comment above. > Now we are back to something directly related to my incompetence. > Bummer. > > On Jul 30, 9:05 am, Andrew Lippert <[email protected]> wrote: > > > > > Sorry!! > > > def self.member_search_sphinx(criteria, vip=false) > > return Member.sphinx_search(criteria[:terms], > > :page => criteria[:page], > > :limit => criteria[:limit], > > :origin => criteria[:origin], > > :distance => criteria[:distance], > > :vip => vip) > > end > > > I'll check the lat/lng stuff. > > > On Jul 30, 9:01 am, Pat Allan <[email protected]> wrote: > > > > Response times ebb and flow - you're just lucky you caught me at the > > > latter :) > > > > You've provided Member.sphinx_search, but you're using > > > Search.member_search_sphinx - got the code for the latter? > > > > Also, it seems the error is happening when the latitude attribute is > > > being set - you don't actually need the set_property calls for the lat/ > > > lng attributes, because your names for them are guessable by Thinking > > > Sphinx. If you wish to keep them anyway, try having the values as > > > symbols, not strings (not that it should make a difference, especially > > > if everything works in development). > > > > Cheers > > > > -- > > > Pat > > > > On 30/07/2009, at 4:49 PM, Andrew Lippert wrote: > > > > > Pat, > > > > > I'm amazed at your response time! > > > > > Everything is working fine in development. It is only the production > > > > server that is having problems. So, I'm sure I've missed something > > > > crucial. > > > > > Here's the code: > > > > > Model - > > > > > define_index do > > > > # fields > > > > indexes first_name > > > > indexes last_name > > > > indexes [first_name, last_name], :as => :full_name > > > > indexes permalink > > > > indexes primary_business_title > > > > indexes primary_business_location > > > > indexes what_i_do > > > > indexes needs > > > > indexes specialties > > > > indexes experience > > > > indexes education > > > > indexes categories.name, :as => :categories > > > > indexes taggings.tag.name, :as => :tags > > > > > # attributes > > > > has membership_level_id, participation_points > > > > has '(membership_level_id + has_primary_image * 150) + IFNULL > > > > (participation_points + 1, 1)', :as => :rating, :type => :integer > > > > has 'RADIANS(primary_business_lat)', :as => :lat, :type => :float > > > > has 'RADIANS(primary_business_long)', :as => :lng, :type > > > > => :float > > > > > # properties > > > > set_property :latitude_attr => 'lat' > > > > set_property :longitude_attr => 'lng' > > > > set_property :field_weights => {:categories => > > > > 5, :primary_business_title => 4, :what_i_do => 3} > > > > set_property :delta => :delayed > > > > > # filter > > > > where "deleted_at IS NULL AND activated_at IS NOT NULL" > > > > > end > > > > > def self.sphinx_search(terms = "", options ={}) > > > > limit = options.delete(:limit) || self.per_page > > > > page = (options.delete(:page) || 1).to_i > > > > page = (page < 1) ? 1 : page > > > > vip = options.delete(:vip) || false > > > > limit = self.vip_per_page if vip > > > > fields = options.delete(:fields) > > > > distance = options.delete(:distance) || Session.default_distance > > > > || self.default_distance > > > > > �...@search_options = { :page => page, > > > > :per_page => limit, > > > > :star => true, > > > > :match_mode => :extended } > > > > > if origin = options.delete(:origin) > > > > lat = (origin[0] / 180.0) * Math::PI > > > > lng = (origin[1] / 180.0) * Math::PI > > > > distance = distance.to_i * 1609.344 > > > > �...@search_options.merge!(:geo => [lat, lng], :with => { "@geodist" > > > > => 0.0..distance }) > > > > end > > > > > if vip > > > > �...@search_options.merge!(:without => { :membership_level_id => > > > > 1..2 }) > > > > end > > > > > �...@search_options.merge!(:sort_mode => :expr, > > > > :sort_by => '@weight * 1.5 + rating' > > > > ) > > > > > results = self.search(terms, @search_options) > > > > > end > > > > > Controller - > > > > > �...@members = Search.member_search_sphinx(@tmp_param[:search]) > > > > > View - > > > > > members.html.erb: > > > > > <div id="search_results"> > > > > <%= render :partial => 'members/list', :object => @members %> > > > > </div> > > > > > _list.html.erb > > > > > <%- > > > > > # members / list > > > > > list ||= @members > > > > paginate = true if paginate.nil? > > > > size ||= 'icon' > > > > up ||= 3 > > > > > # little shortcut > > > > is_cat = (params[:action] == "category") > > > > num_per_page = is_cat ? Member.per_cat_page : Member.per_page > > > > path = is_cat ? "/#...@city[:name].downcase.gsub(/\s/, '-')}/# > > > > {[email protected]}" : search_path('members') > > > > > if list.total_entries > 0 > > > > > -%> > > > > > Exception: > > > > > ActionView::TemplateError: You have a nil object when you didn't > > > > expect it! You might have expected an instance of Array. The error > > > > occurred while evaluating nil.length > > > > > On line #16 of app/views/members/_list.html.erb > > > > > 13: num_per_page = is_cat ? Member.per_cat_page : Member.per_page > > > > > 14: path = is_cat ? "/#...@city[:name].downcase.gsub(/\s/, '-')}/# > > > > {[email protected]}" : search_path('members') > > > > > 15: > > > > > 16: if list.total_entries > 0 > > > > > 17: > > > > > 18: -%> > > > > > 19: > > > > > [GEM_ROOT]/gems/freelancing-god-thinking-sphinx-1.2.1/lib/./vendor/ > > > > riddle/lib/riddle/client/message.rb:20:in `send' > > > > > [GEM_ROOT]/gems/freelancing-god-thinking-sphinx-1.2.1/lib/./vendor/ > > > > riddle/lib/riddle/client/message.rb:20:in `append_string' > > > > > [GEM_ROOT]/gems/freelancing-god-thinking-sphinx-1.2.1/lib/./vendor/ > > > > riddle/lib/riddle/client.rb:531:in `query_message' > > > > > [GEM_ROOT]/gems/freelancing-god-thinking-sphinx-1.2.1/lib/./vendor/ > > > > riddle/lib/riddle/client.rb:286:in `query' > > > > > [GEM_ROOT]/gems/freelancing-god-thinking-sphinx-1.2.1/lib/ > > > > thinking_sphinx/search.rb:203:in `populate' > > > > > [GEM_ROOT]/gems/freelancing-god-thinking-sphinx-1.2.1/lib/ > > > > thinking_sphinx/search.rb:279:in `call' > > > > > [GEM_ROOT]/gems/freelancing-god-thinking-sphinx-1.2.1/lib/ > > > > thinking_sphinx/search.rb:279:in `retry_on_stale_index' > > > > > [GEM_ROOT]/gems/freelancing-god-thinking-sphinx-1.2.1/lib/ > > > > thinking_sphinx/search.rb:200:in `populate' > > > > > [GEM_ROOT]/gems/freelancing-god-thinking-sphinx-1.2.1/lib/ > > > > thinking_sphinx/search.rb:149:in `total_entries' > > > > > app/views/members/_list.html.erb:16 > > > > > app/views/search/members.html.erb:14 > > > > > app/views/search/members.html.erb:12 > > > > > app/controllers/search_controller.rb:101:in `members' > > > > > Thank you for taking a look!! > > > > > On Jul 30, 8:35 am, Pat Allan <[email protected]> wrote: > > > >> Hi Andrew > > > > >> What's the output from production.log? And what's the line of code > > > >> where you're calling the search method? > > > > >> -- > > > >> Pat > > > > >> On 30/07/2009, at 4:25 PM, Andrew Lippert wrote: > > > > >>> I have a properly configured and functioning development environment > > > >>> configured with the latest Ruby Enterprise, Passenger, Thinking > > > >>> Sphinx, Sphinx, etc. Everything works fine. > > > > >>> I have deployed to production. All software installs went well, > > > >>> migrations applied, etc. > > > > >>> I am able to successfully run searchd against a newly created index > > > >>> built using the rake tasks. I can use console to search my model > > > >>> successfully. HOWEVER, when access the application I am getting nil > > > >>> results returned to the views causing all sorts of exceptions. > > > > >>> Here's the sphinx.yml - > > > > >>> production: > > > >>> enable_star: 1 > > > >>> min_prefix_length: 3 > > > >>> min_infix_length: 4 > > > >>> morphology: stem_en > > > >>> config_file: /home/www/biznik.com/shared/config/ > > > >>> production.sphinx.conf > > > >>> searchd_file_path: /home/www/biznik.com/shared/db/sphinx/ > > > >>> production > > > >>> searchd_log_file: /home/www/biznik.com/shared/log/searchd.log > > > >>> query_log_file: /home/www/biznik.com/shared/log/searchd.query.log > > > >>> pid_file: /home/www/biznik.com/shared/pids/searchd.production.pid > > > >>> bin_path: /usr/local/bin > > > > >>> Samples from the searchd log file look like the service is not being > > > >>> hit when the model is searched from the production app: > > > > >>> [Thu Jul 30 08:13:52.829 2009] 0.000 sec [scan/2/rel 1 (0,20)] > > > >>> [member_core] > > > >>> [Thu Jul 30 08:14:39.027 2009] 0.000 sec [scan/2/rel 1 (0,20)] > > > >>> [member_core] > > > >>> [Thu Jul 30 08:17:31.074 2009] 0.000 sec [scan/2/rel 1 (0,20)] > > > >>> [member_core] > > > >>> [Thu Jul 30 08:18:03.899 2009] 0.000 sec [scan/2/rel 1 (0,20)] > > > >>> [member_core] > > > >>> [Thu Jul 30 08:18:09.384 2009] 0.000 sec [scan/2/rel 1 (0,20)] > > > >>> [member_core] > > > >>> [Thu Jul 30 08:18:40.661 2009] 0.000 sec [scan/2/rel 1 (0,20)] > > > >>> [member_core] > > > >>> [Thu Jul 30 08:19:11.654 2009] 0.000 sec [scan/2/rel 1 (0,20)] > > > >>> [member_core] > > > >>> [Thu Jul 30 08:20:35.390 2009] 0.000 sec [scan/2/rel 1 (0,20)] > > > >>> [member_core] > > > >>> [Thu Jul 30... > > 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 -~----------~----~----~----~------~----~------~--~---
