I am trying to index the following items for story, however when I add 
tag(:name) and response.body it gives me a syntax error (see below). 
Without the associations, the indexes on title and body work fine. But when 
I add associations it crashes. Any ideas? Thank you. 

*story_index.rb*

ThinkingSphinx::Index.define :story, with: :active_record do
  indexes title, sortable: true
  indexes body

  indexes tag(:name), as: :tag, sortable: true
  indexes response.body, as: :response_body, sortable: true

  has created_at, updated_at
end

*story.rb*

class Story < ActiveRecord::Base
  include TagListable

  belongs_to :user
  has_many :likes, dependent: :destroy
  has_many :responses, dependent: :destroy
  has_many :taggings, as: :taggable
  has_many :tags, through: :taggings

  validates :body, presence: true
  validates :title, presence: true
  validates :user, presence: true

  def self.recent
    order(created_at: :desc).limit(9)
  end
end


*error*

Generating configuration to 
/Users/metis/i_am_mixed/config/development.sphinx.conf
Sphinx 2.1.8-release (rel21-r4675)
Copyright (c) 2001-2014, Andrew Aksyonoff
Copyright (c) 2008-2014, Sphinx Technologies Inc (http://sphinxsearch.com)

using config file 
'/Users/metis/i_am_mixed/config/development.sphinx.conf'...
indexing index 'response_core'...
collected 1 docs, 0.0 MB
sorted 0.0 Mhits, 100.0% done
total 1 docs, 10 bytes
total 0.016 sec, 593 bytes/sec, 59.35 docs/sec
indexing index 'story_core'...
ERROR: index 'story_core': sql_range_query: ERROR:  syntax error at or near 
"AS"
LINE 1: ...es."title" AS "title", stories."body" AS "body",  AS "tag", ...
                                                             ^
 (DSN=pgsql://metis:***@localhost:5432/i_am_mixed_development).
total 0 docs, 0 bytes
total 0.005 sec, 0 bytes/sec, 0.00 docs/sec
indexing index 'tag_core'...
collected 12 docs, 0.0 MB
sorted 0.0 Mhits, 100.0% done
total 12 docs, 40 bytes
total 0.011 sec, 3353 bytes/sec, 1005.95 docs/sec
skipping non-plain index 'response'...
skipping non-plain index 'story'...
skipping non-plain index 'tag'...
total 6 reads, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
total 20 writes, 0.000 sec, 0.1 kb/call avg, 0.0 msec/call avg



*My schema*


  create_table "responses", force: true do |t|
    t.integer  "user_id",    null: false
    t.integer  "story_id",   null: false
    t.text     "body",       null: false
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end

  add_index "responses", ["story_id"], name: "index_responses_on_story_id", 
using: :btree
  add_index "responses", ["user_id"], name: "index_responses_on_user_id", 
using: :btree

  create_table "stories", force: true do |t|
    t.string   "image",      default: "", null: false
    t.integer  "user_id",                 null: false
    t.string   "title",                   null: false
    t.text     "body",                    null: false
    t.datetime "created_at",              null: false
    t.datetime "updated_at",              null: false
  end

  add_index "stories", ["user_id"], name: "index_stories_on_user_id", 
using: :btree

  create_table "taggings", force: true do |t|
    t.integer "taggable_id",   null: false
    t.string  "taggable_type", null: false
    t.integer "tag_id",        null: false
  end

  add_index "taggings", ["taggable_id", "tag_id"], name: 
"index_taggings_on_taggable_id_and_tag_id", unique: true, using: :btree

  create_table "tags", force: true do |t|
    t.string   "name",       null: false
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end

  add_index "tags", ["name"], name: "index_tags_on_name", unique: true, 
using: :btree

-- 
You received this message because you are subscribed to the Google Groups 
"Thinking Sphinx" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/thinking-sphinx.
For more options, visit https://groups.google.com/d/optout.

Reply via email to