哦? 我现在用的MYSQL 建立项目后 按照网上的添加完了 rake ts:in 都成功了
控制器 search
model article:
class Article < ActiveRecord::Base
define_index do
indexes :title
indexes classid
has :subclassid,:published,:status
set_property :delta=>true
end
end
----数据库字段
class CreateArticles < ActiveRecord::Migration
def self.up
create_table :articles do |t|
t.column :classid,:integer,:limit=>20,:null=>false
t.column :subclassid,:integer,:limit=>20,:null=>false
t.column :title,:string,:null=>false
t.column :published,:integer,:null=>false,:default=>0
t.column :comment_count,:integer,:null=>false,:default=>0
t.column :status,:integer,:null=>false,:default=>0
#t.timestamps
end
end
def self.down
drop_table :articles
end
end
---在Gemfile 里面加
gem 'thinking-sphinx','2.0.5',:require=>'thinking_sphinx'require '
---在Rakefile 里面加
require ‘thinking_sphinx/tasks'
---在config/application.rb加
config.gem(
'thinking-sphinx',
:lib=>'thinking_sphinx'
)
在启动rails server 服务的时候提示 Sphinx cannot be found on your system. You may need to configure the following
settings in your config/sphinx.yml file:
* bin_path
* searchd_binary_name
* indexer_binary_name
sphin.yml如下:
development: &my_settings
listen: localhost:9312
charset_dictpath: "db/sphinx/development/"
charset_type: "zh_cn.utf-8"
mem_limit: '256M'
test:
<<: *my_settings
production:
<<: *my_settings
-----------------------------------------
最后搜索提示 unknown local index 'article_core' in search request
-----------------
不知道哪里不对。。
可以帮忙看下吗???
--
http://www.boolsir.com