zoukankan      html  css  js  c++  java
  • coreseek sphinx rails3给力中文文档

    http://tjcjc.iteye.com/blog/766863
    http://tongxiaoming520.iteye.com/blog/844988
    以上两篇都很给力
    http://www.iteye.com/topic/487608
    2010-09-19

    mysql thinking_sphinx coreseek rails3

    版本:coreseek 3.2.13   thinking_spinx 2.0.0.rc2 rails3.0.0

    在linux下修改3个my.cnf的1个/etc/mysql/my.cnf文件

    找到客户端配置[client] 在下面添加
    default-character-set=utf8 默认字符集为utf8
    在找到[mysqld] 添加
    default-character-set=utf8 默认字符集为utf8
    init_connect='SET NAMES utf8' (设定连接mysql数据库时使用utf8编码,以让mysql数据库为utf8运行)

    修改好后,重新启动mysql 即可,
    sudo /etc/init.d/mysql restart
    查询一下show variables like 'character%';
    +--------------------------+----------------------------+
    | Variable_name | Value |
    +--------------------------+----------------------------+
    | character_set_client | utf8 |
    | character_set_connection | utf8 |
    | character_set_database | utf8 |
    | character_set_filesystem | binary |
    | character_set_results | utf8 |
    | character_set_server | utf8 |
    | character_set_system | utf8 |
    | character_sets_dir | /usr/share/mysql/charsets/ |
    +--------------------------+----------------------------+

    这样就不用每次连接 都使用  --default-character-set=utf8 了

    安装:
    coreseek
    按照网站上的下载安装
    thinking_sphinx
    gem install --pre

    配置:
    gemfile中
    gem 'thinking-sphinx', '2.0.0.rc2', :require => 'thinking_sphinx'
    config/sphinx.yml中
    development:
      charset_type: zh_ch.utf-8
      bin_path: coreseek的目录/bin
      charset_dictpath: mmseg3的目录/etc

    使用:
    model中
    define_index do
    indexes :introduction #model的一个字段 indexes就会检索这个字段
    end

    rails/app目录下
    rake thinking_sphinx:configure
    rake thinking_sphinx:index
    rake thinking_sphinx:start

    几个使用中出现的错误
    1.
    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
    这个可以忽略 因为用的是coreseek 所以他会说没有找到sphinx

    2.
    index时
    FATAL: index 'video_core': unknown charset type 'zh_cn.utf-8'
    这个是因为没有在config/sphinx.yml中配置charset_dictpath

    3.
    start
    Failed to start searchd daemon
    这个是因为coreseek安装以后会自动运行 会有一个deamon的进程
    需要kill掉它
    ps -aef|gref deamon
    kill 进程号
    然后再rake start命令

    4.Riddle cannot detect Sphinx on your machine, and so can't determine which
    version of Sphinx you are planning on using. Please use one of the following
    lines after "require 'riddle'" to avoid this warning.

      require 'riddle/0.9.8'
      # or
      require 'riddle/0.9.9'
      # or
      require 'riddle/1.10'
    这个警告也可以忽略

    5.每次更新了数据都需要重新index一遍 但是不需要restart 他会自动更新   

  • 相关阅读:
    UVALive-8077 Brick Walls 找规律
    UVALive-8079 Making a Team 排列组合公式化简
    UVALive-8072 Keeping On Track 树形dp 联通块之间缺失边的个数
    HDU-5534 Partial Tree 完全背包 设定初始选择
    HDU-2844 Coins 多重背包 物品数量二进制优化
    CodeForces-366C Dima and Salad 对01背包的理解 多个背包问题
    HDU-2955 Robberies 浮点数01背包 自变量和因变量位置互换
    UVALive-7197 Axles 动态规划 多个背包问题
    广义表(C++实现)
    稀疏矩阵及稀疏矩阵的压缩存储
  • 原文地址:https://www.cnblogs.com/lexus/p/2143760.html
Copyright © 2011-2022 走看看