配置思维狮身人面像与英语或俄语以外的形态

时间:2017-03-10 18:58:42

标签: ruby-on-rails ruby-on-rails-3.2 sphinx thinking-sphinx

我需要用西班牙语词干配置思维狮身人面像,我无法让它发挥作用。

我学会了[1]我需要用libstemmer_c库编译sphinx源代码并安装它。另外,我必须通过将libstemmer_es词干分析器添加到形态学来改变思维sphinx的配置。

详细而言,这就是我所做的

  1. 使用apt-get

    删除现有的sphinx安装
    $(this.selectorButton).on('click', $.proxy(this._handleClick, this));
    
    this._handleClick = function () {
        // here this would be a reference to the object.
    };
    
  2. 下载并解压缩sphinx和libstemmer_c库的源代码,并将后者的内容复制到libstemmer_c目录

     apt-get remove sphinxsearch
    
  3. 使用libstemmer_c库配置,编译和安装sphinx

     wget http://sphinxsearch.com/files/sphinx-2.2.11-release.tar.gz
     tar xvf sphinx-2.2.11-release.tar.gz
     wget http://snowball.tartarus.org/dist/libstemmer_c.tgz
     tar xvf libstemmer_c.tgz
     cp -rf libstemmer_c/* sphinx-2.2.11-release/libstemmer_c/
    
  4. 在thinking_sphinx.yml

    中将libstemmer_es词干分析器添加到形态学中
    cd sphinx-2.2.11-release
    ./configure --with-mysql-includes=/usr/include/mysql --with-mysql-libs=/usr/lib/x86_64-linux-gnu --with-libstemmer
    make          
    make install
    
  5. 重新配置sphinx并重新生成索引

    development:
      mysql41: 3563
      address: <%= ENV['SPHINX_HOST'] || '' %>
      enable_star: true
      charset_type: utf-8
      min_infix_len: 2
      morphology: libstemmer_es
      ...
    
  6. 重新启动docker容器和rails服务器

  7. 我正在开发一个网站,其中包含使用sphinx索引的各种产品。通过词干分析,搜索“摄像机”可以产生带有“摄像机”或“摄像机”的所有产品。目前,搜索“相机”仅返回字符串中带有“相机”的产品,但不包含仅带“相机”的产品。

    我在Ubuntu 14.04.4 LTS上使用Rails 3.2,think-sphinx 3.2和sphinx 2.2.11。也许值得一提的是我正在使用docker容器。 searchd在除rails应用程序之外的单独容器中运行。

    更新1:我无法执行bundle exec rake ts:configure bundle exec rake ts:generate ,因为我在一个单独的docker-container中运行 searchd ,即我的sphinx容器。相反,我停止sphinx容器,输入工作容器,运行rake ts:regeneraterake ts:clear_rt,然后重新启动sphinx容器,该容器也重新启动 - searchd ,进入sphinx容器,然后完成运行rake ts:configure

    更新2:log / development.searchd.log的内容是

    rake ts:generate

    更新3:我正在定义具有标题,描述,作者姓名等属性的产品列表的实时索引。

    [Thu Mar 16 12:24:59.147 2017] [  127] listening on all interfaces, port=3563
    [Thu Mar 16 12:24:59.161 2017] [  127] binlog: replaying log .../development/binlog.001
    [Thu Mar 16 12:24:59.161 2017] [  127] binlog: replay stats: 0 rows in 0 commits; 0 updates, 0 reconfigure; 0 indexes
    [Thu Mar 16 12:24:59.162 2017] [  127] binlog: finished replaying /opt/sharetribe/tmp/binlog/development/binlog.001; 0.0 MB in 0.000 sec
    [Thu Mar 16 12:24:59.162 2017] [  127] binlog: finished replaying total 1 in 0.001 sec
    [Thu Mar 16 12:24:59.163 2017] [  127] DEBUG: SaveMeta: Done.
    [Thu Mar 16 12:24:59.163 2017] [  127] accepting connections
    [Thu Mar 16 12:25:04.175 2017] [  127] DEBUG: ReadLock 0xe42ef8
    [Thu Mar 16 12:25:04.175 2017] [  127] DEBUG: Unlock 0xe42ef8
    [Thu Mar 16 12:25:04.175 2017] [  127] DEBUG: ReadLock 0xe42ef8
    [Thu Mar 16 12:25:04.175 2017] [  127] DEBUG: Unlock 0xe42ef8
    [Thu Mar 16 12:25:04.175 2017] [  127] DEBUG: ReadLock 0xe42ef8
    [Thu Mar 16 12:25:04.175 2017] [  127] DEBUG: Unlock 0xe42ef8
    ... /* many more ReadLock and Unlock */
    [Thu Mar 16 12:28:50.467 2017] [  128] listening on all interfaces, port=3563
    [Thu Mar 16 12:28:50.478 2017] [  128] DEBUG: SaveMeta: Done.
    [Thu Mar 16 12:28:50.478 2017] [  128] accepting connections
    [Thu Mar 16 12:28:55.503 2017] [  128] DEBUG: ReadLock 0x1522ef8
    [Thu Mar 16 12:28:55.503 2017] [  128] DEBUG: Unlock 0x1522ef8
    [Thu Mar 16 12:25:04.175 2017] [  127] DEBUG: ReadLock 0xe42ef8
    [Thu Mar 16 12:25:04.175 2017] [  127] DEBUG: Unlock 0xe42ef8
    [Thu Mar 16 12:25:04.175 2017] [  127] DEBUG: ReadLock 0xe42ef8
    [Thu Mar 16 12:25:04.175 2017] [  127] DEBUG: Unlock 0xe42ef8
    ... /* many more ReadLock and Unlock */
    [Thu Mar 16 12:29:09.806 2017] [  128] caught SIGHUP (seamless=1, in queue=1)
    [Thu Mar 16 12:29:09.806 2017] [  128] DEBUG: CheckRotate invoked
    [Thu Mar 16 12:29:09.806 2017] [  128] DEBUG: /opt/sharetribe/db/sphinx/development/custom_field_value_core.new.sph is not readable. Skipping
    [Thu Mar 16 12:29:09.806 2017] [  128] DEBUG: /opt/sharetribe/db/sphinx/development/listing_core.new.sph is not readable. Skipping
    [Thu Mar 16 12:29:09.806 2017] [  128] WARNING: nothing to rotate after SIGHUP ( in queue=0 )
    [Thu Mar 16 12:29:10.541 2017] [  128] DEBUG: ReadLock 0x1522ef8
    [Thu Mar 16 12:29:10.541 2017] [  128] DEBUG: Unlock 0x1522ef8
    [Thu Mar 16 12:25:04.175 2017] [  127] DEBUG: ReadLock 0xe42ef8
    [Thu Mar 16 12:25:04.175 2017] [  127] DEBUG: Unlock 0xe42ef8
    [Thu Mar 16 12:25:04.175 2017] [  127] DEBUG: ReadLock 0xe42ef8
    [Thu Mar 16 12:25:04.175 2017] [  127] DEBUG: Unlock 0xe42ef8
    ... /* many more ReadLock and Unlock */
    

    这是基础模型

    ThinkingSphinx::Index.define :listing, :with => :real_time do
      indexes title
      indexes description
      indexes custom_field_values_sphinx
      indexes origin_loc.google_address
      indexes author.given_name
      indexes author.username
      indexes location.province
    ...
    

    在模型的公共方法

    中调用Listing.search方法
    class Listing < ActiveRecord::Base 
    
      after_save ThinkingSphinx::RealTime.callback_for(:listing)
    ...
    

    [1] http://freelancing-gods.com/thinking-sphinx/advanced_config.html#word-stemming--morphology

1 个答案:

答案 0 :(得分:0)

从我所看到的,你已经正确配置了所有内容。

您可能希望运行rake ts:regenerate以确保Sphinx正确加载新配置(ts:generate用于更新数据,但不更新配置)。

如果它没有改变任何东西(并且形态设置出现在生成的配置文件中),那么问题可能不在于TS,而在于Sphinx本身?我想知道Sphinx日志是否有任何线索。