tag:support.flying-sphinx.com,2011-01-05:/discussions/problems/128-heroku-thinkingsphinxsphinxerror-no-enabled-local-indexes-to-searchFlying Sphinx: Discussion 2016-08-11T01:37:00Ztag:support.flying-sphinx.com,2011-01-05:Comment/130859352012-01-22T22:33:56Z2012-01-22T22:33:56Zheroku ThinkingSphinx::SphinxError (no enabled local indexes to search):<div><p>Hi William</p>
<p>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.</p>
<p>Pat</p></div>Pat Allantag:support.flying-sphinx.com,2011-01-05:Comment/130859352012-01-22T22:38:59Z2012-01-22T22:38:59Zheroku ThinkingSphinx::SphinxError (no enabled local indexes to search):<div><p>foa.herokuapp.com</p>
<p>Thanks!</p>
<p>William Voll<br>
<a href="mailto:wpvoll@gmail.com">wpvoll@gmail.com</a><br>
<a href="http://about.me/zdweeb">http://about.me/zdweeb</a></p></div>William Volltag:support.flying-sphinx.com,2011-01-05:Comment/130859352012-01-22T23:03:09Z2012-01-22T23:03:09Zheroku ThinkingSphinx::SphinxError (no enabled local indexes to search):<div><p>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?</p></div>Pat Allantag:support.flying-sphinx.com,2011-01-05:Comment/130859352012-01-23T17:52:42Z2012-01-23T17:52:42Zheroku ThinkingSphinx::SphinxError (no enabled local indexes to search):<div><p>Pat,</p>
<p>First thank you so much for your help.</p>
<p>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.</p>
<p>class Static < ActiveRecord::Base<br>
has_one :box_element, :foreign_key => :element_id</p>
<p>define_index do</p>
<pre>
<code>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</code>
</pre>
<p>end</p>
<p>def installment</p>
<pre>
<code>box_element.box.installment</code>
</pre>
<p>end end</p>
<p>I had to change this Model to add columns in the group by
clause;</p>
<p>class Topic < ActiveRecord::Base<br>
include ActionView::Helpers::TextHelper acts_as_tree</p>
<p>belongs_to :category, :class_name => 'ForumCategory',</p>
<pre>
<code>:foreign_key => :category_id</code>
</pre>
<p>belongs_to :user has_many :posts, :dependent => :destroy</p>
<p>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')</p>
<p>accepts_nested_attributes_for :posts
accepts_nested_attributes_for :parent</p>
<p>acts_as_followable</p>
<p>define_index do</p>
<pre>
<code>indexes title
has created_at
has updated_at
has user_id
has parent_id</code>
</pre>
<p>end</p>
<p>def subtopic?</p>
<pre>
<code>parent.present?</code>
</pre>
<p>end</p>
<p>def parent_topic</p>
<pre>
<code>try(:parent)</code>
</pre>
<p>end</p>
<p>alias_method :category!, :category def category</p>
<pre>
<code>subtopic? ? parent.try(:category) : category!</code>
</pre>
<p>end</p>
<p>def forum</p>
<pre>
<code>category.try(:forum)</code>
</pre>
<p>end</p>
<p>def book</p>
<pre>
<code>category.try(:installment).try(:book)</code>
</pre>
<p>end</p>
<p>def child_posts</p>
<pre>
<code>if subtopic?
@child_posts ||= posts.order(&:created_at)
else
@child_posts ||= children.map{|t| t.posts}.flatten.compact.sort_by(&:created_at)
end</code>
</pre>
<p>end</p>
<p>def contributors</p>
<pre>
<code>@contributors ||= child_posts.map(&:user).uniq</code>
</pre>
<p>end</p>
<p>def build_parent_topic</p>
<pre>
<code>unless subtopic?
build_parent(
:title => title,
:description => description,
:user_id => user_id,
:category_id => category_id
)
self.description = nil
self.category_id = nil
end</code>
</pre>
<p>end</p>
<p>def make_as_parent</p>
<pre>
<code>self.description = parent.description
self.category_id = parent.category_id
self.parent = nil</code>
</pre>
<p>end</p>
<p>def contributor_list</p>
<pre>
<code>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</code>
</pre>
<p>end end</p>
<p>William Voll<br>
<a href="mailto:wpvoll@gmail.com">wpvoll@gmail.com</a><br>
<a href="http://about.me/zdweeb">http://about.me/zdweeb</a></p></div>William Volltag:support.flying-sphinx.com,2011-01-05:Comment/130859352012-01-24T11:30:48Z2012-01-24T11:30:48Zheroku ThinkingSphinx::SphinxError (no enabled local indexes to search):<div><p>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?</p>
<p>Pat</p></div>Pat Allantag:support.flying-sphinx.com,2011-01-05:Comment/130859352012-01-25T14:12:20Z2012-01-25T14:12:20Zheroku ThinkingSphinx::SphinxError (no enabled local indexes to search):<div><p>I thought I did be for contacting the board, I will try
again.</p>
<p>William Voll<br>
<a href="mailto:wpvoll@gmail.com">wpvoll@gmail.com</a><br>
<a href="http://about.me/zdweeb">http://about.me/zdweeb</a></p></div>William Volltag:support.flying-sphinx.com,2011-01-05:Comment/130859352012-01-26T13:04:43Z2012-01-26T13:04:43Zheroku ThinkingSphinx::SphinxError (no enabled local indexes to search):<div><p>Looks like indexing was successful in recent attempts - does
searching work fine now for you?</p></div>Pat Allan