• 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 他会自动更新   

  • 相关阅读:
    MATLAB GUI制作快速入门
    JavaFX Chart设置数值显示
    Unity查找物体的四大主流方法及区别
    Matlab 图像转极坐标系
    使用python获得N个区分度较高的RGB颜色值
    Arduino学习笔记30
    Arduino学习笔记27
    Arduino学习笔记26
    Arduino学习笔记25
    Arduino学习笔记24
  • 原文地址:https://www.cnblogs.com/lexus/p/2143760.html
Copyright © 2020-2023  润新知