heroku ThinkingSphinx::SphinxError (no enabled local indexes to search):

William's Avatar

William

22 Jan, 2012 08:11 PM

I get this when I run;

heroku run fs:rebuild

Locally it indexes and search works.

  1. Support Staff 1 Posted by Pat Allan on 22 Jan, 2012 10:33 PM

    Pat Allan's Avatar

    Hi William

    Can you let me know what the name of your app is? I'll investigate and make sure everything's fine on the server side of things.

    Pat

  2. 2 Posted by William Voll on 22 Jan, 2012 10:38 PM

    William Voll's Avatar

    foa.herokuapp.com

    Thanks!

    William Voll
    [email blocked]
    http://about.me/zdweeb

  3. Support Staff 3 Posted by Pat Allan on 22 Jan, 2012 11:03 PM

    Pat Allan's Avatar

    I'm guessing you're getting this error when searching on Static? There's something not quite right with your index definition in your Static model - either that, or your migrations on the server aren't up to date. Can you confirm the latter, and share your define_index block?

  4. 4 Posted by William Voll on 23 Jan, 2012 05:52 PM

    William Voll's Avatar

    Pat,

    First thank you so much for your help.

    Yes this Model is a problem, I inherited this code so I am not sure if we need it, but would like to get it working just the same.

    class Static < ActiveRecord::Base
      has_one :box_element, :foreign_key => :element_id

      define_index do
        indexes :title, :sortable => true
        indexes :html

        #has created_at
        #has updated_at
        #has box_element.box.title, :as => :box_title
        #has "CAST #{box_element.box.installment.title} AS UNSIGNED INT)", :type => :integer, :as => :installment_title
        #has "CAST #{box_element.box.installment_id} AS UNSIGNED INT)", :type => :integer, :as => :installment_id
        #has "CAST #{box_element.box.installment.chapter_id} AS UNSIGNED INT)", :type => :integer, :as => :chapter_id
      end

      def installment
        box_element.box.installment
      end
    end

    I had to change this Model to add columns in the group by clause;

    class Topic < ActiveRecord::Base
      include ActionView::Helpers::TextHelper
      acts_as_tree

      belongs_to :category, :class_name => 'ForumCategory',
        :foreign_key => :category_id
      belongs_to :user
      has_many :posts, :dependent => :destroy

      validates :title, :presence => true
      validates :category_id, :presence => true, :unless => :subtopic?
      validates :user_id, :presence => true
      scope :subtopic, where('parent_id is not null')
      scope :order_by_posts, joins(:posts).order('posts.created_at desc').group('topics.created_at','topics.updated_at'',topics.user_id','topics.description','topics.parent_id','topics.id','posts.created_at', 'topics.title', 'topics.category_id')

      accepts_nested_attributes_for :posts
      accepts_nested_attributes_for :parent

      acts_as_followable
      
      define_index do
        indexes title

        has created_at
        has updated_at
        has user_id
        has parent_id
      end

      def subtopic?
        parent.present?
      end
      
      def parent_topic
        try(:parent)
      end

      alias_method :category!, :category
      def category
        subtopic? ? parent.try(:category) : category!
      end

      def forum
        category.try(:forum)
      end

      def book
        category.try(:installment).try(:book)
      end

      def child_posts
        if subtopic?
          @child_posts ||= posts.order(&:created_at)
        else
          @child_posts ||= children.map{|t| t.posts}.flatten.compact.sort_by(&:created_at)
        end
      end

      def contributors
        @contributors ||= child_posts.map(&:user).uniq
      end

      def build_parent_topic
        unless subtopic?
          build_parent(
            :title => title,
            :description => description,
            :user_id => user_id,
            :category_id => category_id
          )
          self.description = nil
          self.category_id = nil
        end
      end

      def make_as_parent
        self.description = parent.description
        self.category_id = parent.category_id
        self.parent = nil
      end

      def contributor_list
        if contributors.count < 4
          contributors.sort_by(&:level).map{|u| u.link}.join(', ')
        else
          list = contributors.sort_by(&:level)
          first_users = list[0..3].map{|u| u.link}.join(', ')
          second_users_count = contributors.count - 3
          second_users = pluralize(second_users_count, 'other')
          "#{first_users}, and #{second_users}"
        end
      end
    end

    William Voll
    [email blocked]
    http://about.me/zdweeb

  5. Support Staff 5 Posted by Pat Allan on 24 Jan, 2012 11:30 AM

    Pat Allan's Avatar

    The issue here in Static is the last three attributes (all commented out) - the column references can't be used as strings in SQL, and that's what was generating an incorrect index definition. Have you deployed and rebuilt your Sphinx setup since commenting those lines out?

    Pat

  6. 6 Posted by William Voll on 25 Jan, 2012 02:12 PM

    William Voll's Avatar

    I thought I did be for contacting the board, I will try again.

    William Voll
    [email blocked]
    http://about.me/zdweeb

  7. Support Staff 7 Posted by Pat Allan on 26 Jan, 2012 01:04 PM

    Pat Allan's Avatar

    Looks like indexing was successful in recent attempts - does searching work fine now for you?

  8. Pat Allan closed this discussion on 17 Oct, 2012 11:42 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac