Closed npearson72 closed 3 years ago
Here is my pg_seach_scope
pg_seach_scope
pg_search_scope :search, against: [:tsv], using: { tsearch: { prefix: true, negation: true, dictionary: 'english', tsvector_column: 'tsv', highlight: { StartSel: '<b>', StopSel: '</b>', MaxWords: 123, MinWords: 456, ShortWord: 4, HighlightAll: true, MaxFragments: 3, FragmentDelimiter: '…' } } }
I'm getting query logs in my results when I use highlight:
[6] pry(main)> results.highlight => "(ts_headline('english', (coalesce(\"searches\".\"tsv\"::text, '')), (to_tsquery('english', ''' ' || 'zapat' || ' ''' || ':*') && to_tsquery('english', ''' ' || 'restaurant' || ' ''' || ':*')), 'StartSel = \"<b>\", StopSel = \"</b>\", MaxFragments = 3, MaxWords = 123, MinWords = 456, ShortWord = 4, FragmentDelimiter = \"…\", HighlightAll = TRUE'))" [7] pry(main)> results.pg_search_highlight_field => "((ts_headline('english', (coalesce(\"searches\".\"tsv\"::text, '')), (to_tsquery('english', ''' ' || 'zapat' || ' ''' || ':*') && to_tsquery('english', ''' ' || 'restaurant' || ' ''' || ':*')), 'StartSel = \"<b>\", StopSel = \"</b>\", MaxFragments = 3, MaxWords = 123, MinWords = 456, ShortWord = 4, FragmentDelimiter = \"…\", HighlightAll = TRUE'))) AS pg_search_highlight, searches.*"
Any ideas?
Turns out I needed to work with the individual records, not the relation. Calling the following works:
results.first.pg_search_highlight_field
Here is my
pg_seach_scope
I'm getting query logs in my results when I use highlight:
Any ideas?