Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-language indexing with searchable column and indexes for same Model #512

Open
alex223125 opened this issue Apr 30, 2023 · 0 comments

Comments

@alex223125
Copy link

Hi,

I'm using pg_search in my project and have 'searchable' column:

class AddSearchableColumnToEntities < ActiveRecord::Migration[7.0]
  def up
    execute <<-SQL
      ALTER TABLE entities
      ADD COLUMN searchable tsvector GENERATED ALWAYS AS (
        setweight(to_tsvector('english', coalesce(title, '')), 'A') ||
        setweight(to_tsvector('english', coalesce(source_page_description,'')), 'B')
      ) STORED;
    SQL
  end

  def down
    remove_column :entities, :searchable
  end
end

Is it possible to create indexes if I'm expecting title and source_page_description being written in other languages, not only in English?

I also have search scope like this:

  include PgSearch::Model
  pg_search_scope :english_global_search,
                  against: {
                    title: 'A',
                    source_page_description: 'B'
                  },
                  using: {
                    tsearch: {
                      dictionary: 'english',
                      tsvector_column: 'searchable',
                      any_word: true,
                      prefix: true
                    }
                  }

I was looking for examples how I can achieve it with pg_search, but only found how to do it with English language.

Is it supported to have multi-language indexes on same model?

Many thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant