views:

147

answers:

1

Error i m getting is:-

mohit@mohit-laptop ~/Desktop/code $ rake thinking_sphinx:index
(in /home/mohit/Desktop/code)
Generating Configuration to /home/mohit/Desktop/code/config/development.sphinx.conf
Sphinx 0.9.9-release (r2117)
Copyright (c) 2001-2009, Andrew Aksyonoff

using config file '/home/mohit/Desktop/code/config/development.sphinx.conf'...
indexing index 'question_core'...
ERROR: index 'question_core': sql_query_range: : macro '$start' not found in match fetch query.
total 0 docs, 0 bytes
total 0.003 sec, 0 bytes/sec, 0.00 docs/sec
distributed index 'question' can not be directly indexed; skipping.
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

My model:-

class Question < ActiveRecord::Base
belongs_to :user
has_many :comments, :as => :commentable, :dependent => :destroy
has_many :answers, :dependent => :destroy
has_many :votes, :as => :votable, :dependent => :destroy

  define_index do
   indexes content
   indexes title
   indexes answers.content, :as=>:answer_content
   indexes [user.first_name + user.last_name], :as=>:user_name
 end
end

EDIT

development.sphinx.conf

indexer
{
}

searchd
{
  listen = 127.0.0.1:9312
  log = /home/mohit/Desktop/code/log/searchd.log
  query_log = /home/mohit/Desktop/code/log/searchd.query.log
  pid_file = /home/mohit/Desktop/code/log/searchd.development.pid
}

source question_core_0
{
  type = mysql
  sql_host = localhost
  sql_user = root
  sql_pass = google
  sql_db = qna_development
  sql_sock = /var/run/mysqld/mysqld.sock
  sql_query_pre = SET NAMES utf8
  sql_query_pre = SET TIME_ZONE = '+0:00'
  sql_query = SELECT SQL_NO_CACHE `questions`.`id` * 1 + 0 AS `id` , `questions`.`content` AS `content`, `questions`.`title` AS `title`, GROUP_CONCAT(DISTINCT IFNULL(`answers`.`content`, '0') SEPARATOR ' ') AS `answer_content`, `questions`.`#<ThinkingSphinx::Index::FauxColumn:0xb6d535c0>` AS `user_name`, `questions`.`id` AS `sphinx_internal_id`, 1333865240 AS `class_crc`, 0 AS `sphinx_deleted` FROM `questions`    LEFT OUTER JOIN `answers` ON answers.question_id = questions.id  WHERE `questions`.`id` >= $start AND `questions`.`id` <= $end GROUP BY `questions`.`id`  ORDER BY NULL
  sql_query_range = SELECT IFNULL(MIN(`id`), 1), IFNULL(MAX(`id`), 1) FROM `questions` 
  sql_attr_uint = sphinx_internal_id
  sql_attr_uint = class_crc
  sql_attr_uint = sphinx_deleted
  sql_query_info = SELECT * FROM `questions` WHERE `id` = (($id - 0) / 1)
}

index question_core
{
  source = question_core_0
  path = /home/mohit/Desktop/code/db/sphinx/development/question_core
  charset_type = utf-8
}

index question
{
  type = distributed
  local = question_core
}
A: 

Ya i got it :-)

  indexes [user.first_name + user.last_name], :as=>:user_name

Syntax mistake. its

indexes [user.first_name , user.last_name], :as=>:user_name
piemesons