加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 如何在嵌套时实现太阳黑子搜索

发布时间:2020-12-17 02:03:45 所属栏目:百科 来源:网络整理
导读:如何扩展我的搜索? 我想在用户按下搜索按钮时在users_controllers #index上搜索用户. 现在我有3个型号. User User_profile Prefecture User_profile具有user_id和prefecture_id等列. 在县模型中,它有它的名称和名称(Exp:California,New York) 现在我像这样
如何扩展我的搜索?
我想在用户按下搜索按钮时在users_controllers #index上搜索用户.

现在我有3个型号.

User > User_profile > Prefecture

User_profile具有user_id和prefecture_id等列.

在县模型中,它有它的名称和名称(Exp:California,New York)

现在我像这样设置models / user.rb.如果我想添加县搜索,我应该添加什么?用户应该能够在加利福尼亚打字,并且它会点击搜索.

searchable do 
    text :user_profile_nickname do
        user_profile.nickname
    end

    text :user_profile_introduction do
        user_profile.introduction
    end

    text :tag_list do 
        tag_list
    end 

end

解决方法

每个用户都将作为文档存储在Solr中,您需要将预制信息提供给用户文档,以便可以搜索.

尝试:

searchable do 
  text :user_profile_nickname do
    user_profile.nickname
  end

  text :user_profile_introduction do
    user_profile.introduction
  end

  text :tag_list do 
    tag_list
  end

  string :prefacture do
     user_profile.prefacture.name
  end

end

我会使用字符串而不是文本,因为您不需要应用文本处理,例如在prefacture上进行词干化.有了太阳黑子,我认为不可能在文本字段上构建方面.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读