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

Enhance Highlight Customization using the columns Option #516

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mmarusyk
Copy link

@mmarusyk mmarusyk commented Aug 23, 2023

Enhance Highlight Customization using the columns Option

This pull request introduces the utilization of the columns option to create customized highlighting for search results in the PgSearch module. The enhancement offers a more flexible and tailored way to generate pg_search_<custom_name>_highlight columns based on specified columns within the model.

Example:


pg_search_scope :search_by_keyword, against: {
    title: 'A',
    body: 'B',
    summary: 'C'
  }, using: {
    tsearch: {
      prefix: true,
      highlight: {
        fields: {
          title: :title,
          content: %i[body summary]
        }
        StartSel: '<mark>',
        StopSel: '</mark>'
      }
    }
  }

Article.by_keyword('account').first.pg_search_title_highlight
=> "How to create <mark>account</mark>?"

Article.by_keyword('account').first.pg_search_content_highligh
 => Select New Agency <mark>Account</mark> and after you create your agency, the <mark>Account</mark> is here."

@mmarusyk mmarusyk force-pushed the feature/highlight-custom-fields branch from cec7c6a to 3610726 Compare August 23, 2023 14:26
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

Successfully merging this pull request may close these issues.

1 participant