【问题标题】:PG_SEARCH gem search specific columns only for JSONPG_SEARCH gem 仅针对 JSON 搜索特定列
【发布时间】:2017-09-06 04:12:08
【问题描述】:

我的 postgres 表中有 jsonb 列,我只想搜索一个键而不是所有键。

例如

Book.create!(details: {authour: 'example', title: 'something'} 

class Book < ApplicationRecord
  include PgSearch
  pg_search_scope :search,
                  against: [
                    :details
                  ]
end

我想搜索标题并忽略作者姓名。

【问题讨论】:

    标签: ruby-on-rails postgresql activerecord pg-search


    【解决方案1】:

    在他们的 GitHub 页面上有一个请求,但目前是 is not supported

    【讨论】:

    【解决方案2】:

    我也遇到了同样的问题,被pg_search_scope :search_for, against: :details, using: { tsearch: { any_word: true } }解决了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-08-24
      • 1970-01-01
      • 1970-01-01
      • 2023-04-10
      • 1970-01-01
      • 1970-01-01
      • 2014-03-14
      • 1970-01-01
      相关资源
      最近更新 更多