When "Highlight retrieved data" checkbox is checked search terms in the returned fulltext fields are wrapped with <strong> tag.
In service.inc there is

<?php
  protected function formatHighlighting($snippet) {
    return preg_replace('#\[(/?)HIGHLIGHT\]#', '<$1strong>', $snippet);
  }
?>

It will be nice to give opportunity to change that hardcoded <strong> tag with some other tags or custom wrapper via settings.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

OanaIlea’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

This issue was closed due to lack of activity over a long period of time. If the issue is still acute for you, feel free to reopen it and describe the current state.

silverham’s picture

Title: Highlight retrieved data checkbox » Configurable Solr Highlight tags
Status: Closed (outdated) » Needs review
FileSize
3.79 KB

Attach patch allow configurable highlights on a per solr server basis. Would be good to allow better styling on these.

drunken monkey’s picture

Thanks a lot for the patch! Looks pretty good.
However, I think we can make this both simpler and more performant by just using str_replace() instead of a regex – patch attached.
Please tell me whether this works for you (or you see anything wrong with the code) and I can commit it.

silverham’s picture

Status: Needs review » Reviewed & tested by the community

Ah i forgot that str_replace() takes arrays - nice one!

New patch works good for me.

drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

Great to hear, thanks for reporting back!
Committed. Thanks again!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.