Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6619933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:02:06+00:00 2026-05-25T21:02:06+00:00

I could not create index with thinking_sphinx for the simple polymorphic schema below. (Note:

  • 0

I could not create index with thinking_sphinx for the simple polymorphic schema below. (Note: I am able to create index from has_many models but I want to create my indexes from ‘belongs_to’ model (Comment).)

For simplicity, I created a sample project which has the schema:

  create_table "articles", :force => true do |t|
    t.string   "title"
    t.text     "body"
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  create_table "comments", :force => true do |t|
    t.text     "content"
    t.integer  "commentable_id"
    t.string   "commentable_type"
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  create_table "photos", :force => true do |t|
    t.string   "title"
    t.datetime "created_at"
    t.datetime "updated_at"
  end

My sample models and index are:

class Article < ActiveRecord::Base
  has_many :comments, :as => :commentable
end


class Photo < ActiveRecord::Base
  has_many :comments, :as => :commentable
end

class Comment < ActiveRecord::Base
  belongs_to :commentable, :polymorphic => true

  define_index do
    indexes commentable_type, :as => :commentable_type
    has commentable_id, :type => :integer, :as => :commentable_id
    indexes commentable.title
  end
end

I have 1 article with 1 comment and 1 photo with 1 comment, for the test. The problem is I could not create index with ruby ‘1.9.2’, rails ‘3.1.0’ and thinking_sphinx ‘2.0.5’. Note, I tried creating index with both 0.99 and 2.0.1 beta releases of sphinx.

I also tried article.title and photo.title for the problematic line. Waiting for working answers.

The error:

(in /Users/mustafat/Desktop/xxx-meta/testlog)
Generating Configuration to /Users/mustafat/Desktop/xxx-meta/testlog/config/development.sphinx.conf
Sphinx 2.0.1-beta (r2792)
Copyright (c) 2001-2011, Andrew Aksyonoff
Copyright (c) 2008-2011, Sphinx Technologies Inc (http://sphinxsearch.com)

using config file '/Users/mustafat/Desktop/xxx-meta/testlog/config/development.sphinx.conf'...
FATAL: no indexes found in config file '/Users/mustafat/Desktop/xxx-meta/testlog/config/development.sphinx.conf'
Failed to start searchd daemon. Check /Users/mustafat/Desktop/xxx-meta/testlog/log/searchd.log.
Failed to start searchd daemon. Check /Users/mustafat/Desktop/xxx-meta/testlog/log/searchd.log

if I try with the code below:

class Comment < ActiveRecord::Base
  belongs_to :commentable, :polymorphic => true

  define_index do
    indexes commentable_type, :as => :commentable_type
    has commentable_id, :type => :integer, :as => :commentable_id
    indexes article.title
  end
end

I am getting the error below:

(in /Users/mustafat/Desktop/xxx-meta/testlog)
Generating Configuration to /Users/mustafat/Desktop/xxx-meta/testlog/config/development.sphinx.conf
Sphinx 2.0.1-beta (r2792)
Copyright (c) 2001-2011, Andrew Aksyonoff
Copyright (c) 2008-2011, Sphinx Technologies Inc (http://sphinxsearch.com)

using config file '/Users/mustafat/Desktop/xxx-meta/testlog/config/development.sphinx.conf'...
indexing index 'comment_core'...
ERROR: index 'comment_core': sql_range_query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' `comments`.`id`, `comments`.`commentable_id` ORDER BY NULL' at line 1 (DSN=mysql://root:***@localhost:3306/xxx_testlog).
total 0 docs, 0 bytes
total 0.003 sec, 0 bytes/sec, 0.00 docs/sec
skipping non-plain index 'comment'...
total 0 reads, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
total 0 writes, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
Failed to start searchd daemon. Check /Users/mustafat/Desktop/xxx-meta/testlog/log/searchd.log.
Failed to start searchd daemon. Check /Users/mustafat/Desktop/xxx-meta/testlog/log/searchd.log
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T21:02:07+00:00Added an answer on May 25, 2026 at 9:02 pm

    As answered on Twitter, this is fixed in the latest release of TS, 2.0.7.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I keep getting: SQL error: ERROR: could not create unique index service_import_checksum_key DETAIL: Key
We get the following error; The request was aborted: Could not create SSL/TLS secure
I could not find any pointers on how to create a menubar icon on
Seeing as a foreign key does not automatically create an index in SQL Server,
Just could not get this one and googling did not help much either.. First
I could not find the function that returns the name of the cell referenced.
I could not find a clear answer to this question elsewhere, so I'll try
I'm sorry I could not think of a better title. The problem is the
i just could not figure out how i will put my data on a
Here is some code I could not get to format properly in markdown, this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.