Rails rails 使用 sunspot-solr 做搜索「已解决」

brucebot · May 07, 2014 · Last by brucebot replied at May 08, 2014 · 3688 hits

前几天开始折腾这个东西,一直跑不起来,也在这里发了贴子问了,http://ruby-china.org/topics/18966

半夜不睡的效果还是好,至少目前跑起来了,搜索已经生效了,可以去 roboticsfaq.com 右边测试一下。

Gemfile

gem 'progress_bar' 
gem 'sunspot_rails', '~> 2.1.0'
gem 'sunspot_solr', github: 'xhj/sunspot', require: 'sunspot_solr'

解决方案:

  1. 使用了@xhj 打包的 sunspot_solr, 具体在 http://ruby-china.org/topics/15897

  2. 直接用 sunspot_solr 来做生产环境了

  3. RAILS_ENV=production bundle exec rake sunspot:solr:start

  4. RAILS_ENV=production bundle exec rake sunspot:solr:reindex 这一部只索引了部分,但是因为org.apache.solr.common.SolrException: Illegal character ((CTRL-CHAR, code 8))的报错停了,这部还没有解决,请帮忙分析一下。

Update: 解决方法

我用

SELECT
    *
FROM
    `some_table`
WHERE
    `some_field` REGEXP ".*[[:cntrl:]]+.*"

找到好多

登录 mysql

update mytable set FieldName = REPLACE(FieldName,'/','');

把所有替换了,于是好了。

我用的 elasticsearch 做全文索引中文分词搜索,不过有个问题是,配置了 strip_html 没有生效,导致可以搜索 div、table 之类的,还没找到解决方法。

#1 楼 @raofeng elas 比 solr 麻烦啊

@brucebot 检查下 fulltext 的字段,看下里面有没有 ^K 这样的 CTRL-CHAR 字符,删掉就可以了!

You need to Sign in before reply, if you don't have an account, please Sign up first.