Commit 6977869c

mo kareem <email@mokhan.ca>
2011-05-27 03:16:36
figured out how to create a sphinx index.
1 parent 63c7358
app/controllers/creations_controller.rb
@@ -3,6 +3,7 @@ class CreationsController < ApplicationController
   # GET /creations
   # GET /creations.xml
   def index
+    # @creations = Creation.search params[:search], :include => :user, :match_mode => :boolean
     @creations = Creation.all
 
     respond_to do |format|
app/models/creation.rb
@@ -7,6 +7,5 @@ class Creation < ActiveRecord::Base
 
   define_index do
     indexes :name
-    indexes user.name :as => :artist, :sortable => true
   end
 end
config/development.sphinx.conf
@@ -0,0 +1,40 @@
+indexer
+{
+}
+
+searchd
+{
+  listen = 127.0.0.1:9312
+  log = /storage/development/sulumo/cake/log/searchd.log
+  query_log = /storage/development/sulumo/cake/log/searchd.query.log
+  pid_file = /storage/development/sulumo/cake/log/searchd.development.pid
+}
+
+source creation_core_0
+{
+  type = pgsql
+  sql_host = localhost
+  sql_user = mo
+  sql_pass = password
+  sql_db = cakeside_development
+  sql_query_pre = SET TIME ZONE 'UTC'
+  sql_query = SELECT "creations"."id" * 1::INT8 + 0 AS "id" , "creations"."name" AS "name", "creations"."id" AS "sphinx_internal_id", 0 AS "sphinx_deleted", 2929256226 AS "class_crc" FROM "creations" WHERE ("creations"."id" >= $start AND "creations"."id" <= $end) GROUP BY "creations"."id", "creations"."name", "creations"."id"
+  sql_query_range = SELECT COALESCE(MIN("id"), 1::bigint), COALESCE(MAX("id"), 1::bigint) FROM "creations" 
+  sql_attr_uint = sphinx_internal_id
+  sql_attr_uint = sphinx_deleted
+  sql_attr_uint = class_crc
+  sql_query_info = SELECT * FROM "creations" WHERE "id" = (($id - 0) / 1)
+}
+
+index creation_core
+{
+  source = creation_core_0
+  path = /storage/development/sulumo/cake/db/sphinx/development/creation_core
+  charset_type = utf-8
+}
+
+index creation
+{
+  type = distributed
+  local = creation_core
+}
Gemfile
@@ -5,6 +5,7 @@ gem 'rails'
 # Bundle edge Rails instead:
 # gem 'rails', :git => 'git://github.com/rails/rails.git'
 
+gem 'rake', '~> 0.8.7'
 gem 'sqlite3-ruby', :require => 'sqlite3'
 gem 'devise'
 gem 'heroku'
@@ -17,7 +18,8 @@ gem 'bcrypt-ruby'
 gem 'json'
 gem 'thinking-sphinx'
 #gem 'postgres'
-#gem 'pg'
+#gem 'postgres-pr'
+gem 'pg'
 
 # Use unicorn as the web server
 # gem 'unicorn'
Gemfile.lock
@@ -108,6 +108,7 @@ GEM
       oa-oauth (= 0.2.6)
       oa-openid (= 0.2.6)
     orm_adapter (0.0.5)
+    pg (0.11.0)
     polyglot (0.3.1)
     pyu-ruby-sasl (0.0.3.3)
     rack (1.2.3)
@@ -131,7 +132,7 @@ GEM
       activesupport (= 3.0.7)
       rake (>= 0.8.7)
       thor (~> 0.14.4)
-    rake (0.9.0)
+    rake (0.8.7)
     rest-client (1.6.1)
       mime-types (>= 1.16)
     riddle (1.3.3)
@@ -183,7 +184,9 @@ DEPENDENCIES
   jquery-rails
   json
   omniauth
+  pg
   rails
+  rake (~> 0.8.7)
   rmagick
   rspec-rails
   sqlite3-ruby