How to enable :tsearch dictionary for pg_search multi-search?

天大地大妈咪最大 提交于 2019-12-05 14:38:37

What you posted is not valid Ruby syntax.

You want something like this:

PgSearch.multisearch_options = {
  :using => {
    :tsearch => {
      :dictionary => "english"
    },
    :trigram => {}
  },
  :ignoring => :accents
}

The reason is that you must use a Hash if you want to have key-value pairs. So essentially, pg_search allows 2 syntaxes:

:using => someArray # such as [:tsearch, :trigram]

which means "use tsearch and trigram, both with the default options"

or

:using => someHash # such as {:tsearch => optionsHash1, :trigram => optionsHash2}

which means "use tsearch with some options from optionsHash1, and use trigram with some options from OptionsHash2"

Let me know if there's anything I can do to clarify. It's pretty basic Ruby syntax, but I understand that the fact that pg_search accepts both formats can be confusing to those who aren't as familiar.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!