Highlight returning strange test
npearson72 opened this issue · comments
Nathan Pearson commented
Here is my 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?
Nathan Pearson commented
Turns out I needed to work with the individual records, not the relation. Calling the following works:
results.first.pg_search_highlight_field