Commit 341a5eaa

production <prod@cakeside.com>
2011-06-25 04:59:31
figured out seach index settings to make search a little fuzzier.
1 parent 5ef7d6a
app/controllers/search_controller.rb
@@ -1,7 +1,6 @@
 class SearchController < ApplicationController
   def index
-    @creations = Creation.search params[:q], :include => :user, :match_mode => :any
+    @creations = Creation.search params[:q], :include => :user, :match_mode => :extended, :star => true, :page => 1, :per_page => 20
     @search = params[:q]
   end
-
 end
app/models/creation.rb
@@ -6,7 +6,7 @@ class Creation < ActiveRecord::Base
   mount_uploader :image, ImageUploader
 
   define_index do
-    indexes :name
+    indexes :name, :sortable => true
     indexes story
   end
 
config/production.sphinx.conf
@@ -18,11 +18,12 @@ source creation_core_0
   sql_pass = password
   sql_db = cakeside_production
   sql_query_pre = SET TIME ZONE 'UTC'
-  sql_query = SELECT "creations"."id" * 1::INT8 + 0 AS "id" , "creations"."name" AS "name", "creations"."story" AS "story", "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"."story", "creations"."id"
+  sql_query = SELECT "creations"."id" * 1::INT8 + 0 AS "id" , "creations"."name" AS "name", "creations"."story" AS "story", "creations"."id" AS "sphinx_internal_id", 0 AS "sphinx_deleted", 2929256226 AS "class_crc", COALESCE("creations"."name", '') AS "name_sort" FROM "creations" WHERE ("creations"."id" >= $start AND "creations"."id" <= $end) GROUP BY "creations"."id", "creations"."name", "creations"."story", "creations"."id", "creations"."name"
   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_attr_str2ordinal = name_sort
   sql_query_info = SELECT * FROM "creations" WHERE "id" = (($id - 0) / 1)
 }
 
@@ -31,6 +32,8 @@ index creation_core
   source = creation_core_0
   path = /home/ubuntu/websites/cakeside.com/db/sphinx/production/creation_core
   charset_type = utf-8
+  min_infix_len = 1
+  enable_star = 1
 }
 
 index creation
config/sphinx.yml
@@ -0,0 +1,8 @@
+development:
+
+test:
+
+production:
+  enable_star: 1
+  min_infix_len: 1
+
.gitignore
@@ -1,7 +1,7 @@
 .bundle
 db/*.sqlite3
 log/*.log
-tmp/**/*
+tmp
 *.swp
 public/uploads/
 db/sphinx/