Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 像雪貂一样根本不搜索_Ruby On Rails_Full Text Search_Acts As Ferret - Fatal编程技术网

Ruby on rails 像雪貂一样根本不搜索

Ruby on rails 像雪貂一样根本不搜索,ruby-on-rails,full-text-search,acts-as-ferret,Ruby On Rails,Full Text Search,Acts As Ferret,我正在尝试让acts_as_ferret在我的rails应用程序中工作。我已经安装了ferretgem。安装了充当雪貂的插件 这就是我的模型现在的样子 class User < ActiveRecord::Base acts_as_ferret :fields => { :first_name => {}, :last_name => {} } 我甚至试着重建索引。不起作用。雪貂日志显示一切进展顺利 这是日志的快照 [user] rebu

我正在尝试让acts_as_ferret在我的rails应用程序中工作。我已经安装了
ferret
gem。安装了充当雪貂的
插件

这就是我的模型现在的样子

class User < ActiveRecord::Base
  acts_as_ferret :fields => {
    :first_name => {},
    :last_name => {}
  }
我甚至试着重建索引。不起作用。雪貂日志显示一切进展顺利

这是日志的快照

    [user] rebuild index with models: [User(id: integer, login: string, email: string, crypted_password: string, salt: string, created_at: datetime, updated_at: datetime, remember_token: string, remember_token_expires_at: datetime, first_name: string, middle_name: string, last_name: string, url_id: string, active: boolean, feature_profile: boolean, type: string, company_id: string)]
    [user] reindexing model User
    [user] reindex model User : 100.00% complete : 0.01 secs to finish
    [user] reopening index at /home/chirantan/workspace/parnunu/index/development/user

    index_for [User(id: integer, login: string, email: string, crypted_password: string, salt: string, created_at: datetime, updated_at: datetime, remember_token: string, remember_token_expires_at: datetime, first_name: string, middle_name: string, last_name: string, url_id: string, active: boolean, feature_profile: boolean, type: string, company_id: string)]
    options: {:limit=>nil, :offset=>nil}
    ar_options: {}
    [user] stored_fields: nil
    [user] query: chi
    -->+(last_name:chi first_name:chi) +(class_name:User)
    [user] now retrieving records from AR with options: {}
    [user] 0 results from AR: []
    Query: chi
    total hits: 0, results delivered: 0

    index_for [User(id: integer, login: string, email: string, crypted_password: string, salt: string, created_at: datetime, updated_at: datetime, remember_token: string, remember_token_expires_at: datetime, first_name: string, middle_name: string, last_name: string, url_id: string, active: boolean, feature_profile: boolean, type: string, company_id: string)]
    options: {:limit=>nil, :offset=>nil}
    ar_options: {}
    [user] stored_fields: nil
    [user] query: %chi%
    -->+(last_name:chi first_name:chi) +(class_name:User)
    [user] now retrieving records from AR with options: {}
    [user] 0 results from AR: []
    Query: %chi%
    total hits: 0, results delivered: 0

    index_for [User(id: integer, login: string, email: string, crypted_password: string, salt: string, created_at: datetime, updated_at: datetime, remember_token: string, remember_token_expires_at: datetime, first_name: string, middle_name: string, last_name: string, url_id: string, active: boolean, feature_profile: boolean, type: string, company_id: string)]
    options: {:limit=>nil, :offset=>nil}
    ar_options: {}
    [user] stored_fields: nil
    [user] query: Chirantan
    -->+(last_name:chirantan first_name:chirantan) +(class_name:User)
    [user] now retrieving records from AR with options: {}
    [user] 0 results from AR: []
    Query: Chirantan
    total hits: 0, results delivered: 0
我在控制台的开发模式下测试这个。我是否错过了一个步骤,或者我是否需要运行一些索引过程(如ThinkingSphinx)?我做错了什么?

尝试查询

User.find_with_ferret 'first_name:Chirantan'

听起来您并不是在搜索所有字段。如果要指定字段,则需要使用默认字段选项。

谢谢。但由于我有几个小时没有得到回应,我改用斯芬克斯,效果非常好。不过我会试试你的建议。
    [user] rebuild index with models: [User(id: integer, login: string, email: string, crypted_password: string, salt: string, created_at: datetime, updated_at: datetime, remember_token: string, remember_token_expires_at: datetime, first_name: string, middle_name: string, last_name: string, url_id: string, active: boolean, feature_profile: boolean, type: string, company_id: string)]
    [user] reindexing model User
    [user] reindex model User : 100.00% complete : 0.01 secs to finish
    [user] reopening index at /home/chirantan/workspace/parnunu/index/development/user

    index_for [User(id: integer, login: string, email: string, crypted_password: string, salt: string, created_at: datetime, updated_at: datetime, remember_token: string, remember_token_expires_at: datetime, first_name: string, middle_name: string, last_name: string, url_id: string, active: boolean, feature_profile: boolean, type: string, company_id: string)]
    options: {:limit=>nil, :offset=>nil}
    ar_options: {}
    [user] stored_fields: nil
    [user] query: chi
    -->+(last_name:chi first_name:chi) +(class_name:User)
    [user] now retrieving records from AR with options: {}
    [user] 0 results from AR: []
    Query: chi
    total hits: 0, results delivered: 0

    index_for [User(id: integer, login: string, email: string, crypted_password: string, salt: string, created_at: datetime, updated_at: datetime, remember_token: string, remember_token_expires_at: datetime, first_name: string, middle_name: string, last_name: string, url_id: string, active: boolean, feature_profile: boolean, type: string, company_id: string)]
    options: {:limit=>nil, :offset=>nil}
    ar_options: {}
    [user] stored_fields: nil
    [user] query: %chi%
    -->+(last_name:chi first_name:chi) +(class_name:User)
    [user] now retrieving records from AR with options: {}
    [user] 0 results from AR: []
    Query: %chi%
    total hits: 0, results delivered: 0

    index_for [User(id: integer, login: string, email: string, crypted_password: string, salt: string, created_at: datetime, updated_at: datetime, remember_token: string, remember_token_expires_at: datetime, first_name: string, middle_name: string, last_name: string, url_id: string, active: boolean, feature_profile: boolean, type: string, company_id: string)]
    options: {:limit=>nil, :offset=>nil}
    ar_options: {}
    [user] stored_fields: nil
    [user] query: Chirantan
    -->+(last_name:chirantan first_name:chirantan) +(class_name:User)
    [user] now retrieving records from AR with options: {}
    [user] 0 results from AR: []
    Query: Chirantan
    total hits: 0, results delivered: 0
User.find_with_ferret 'first_name:Chirantan'