Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#3 | 1845920-3--configurable_highlighting_tags.patch | 3.03 KB | drunken monkey |
Comments
Comment #1
OanaIlea CreditAttribution: OanaIlea at bio.logis Genetic Information Management GmbH commentedThis 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.
Comment #2
silverham CreditAttribution: silverham at EY Digital commentedAttach patch allow configurable highlights on a per solr server basis. Would be good to allow better styling on these.
Comment #3
drunken monkeyThanks 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.
Comment #4
silverham CreditAttribution: silverham at EY Digital commentedAh i forgot that str_replace() takes arrays - nice one!
New patch works good for me.
Comment #6
drunken monkeyGreat to hear, thanks for reporting back!
Committed. Thanks again!