Closed Deewde closed 2 years ago
I'm using the CustomizeRequest
plugin for this:
$customizer = $client->getPlugin('customizerequest');
$hlOptions = array(
'method' => 'unified',
'tag.pre' => '<strong>',
'tag.post' => '</strong>',
'defaultSummary' => 'true',
'offsetSource' => 'ANALYSIS'
);
foreach($hlOptions as $name => $value) {
$customizer->createCustomization(array(
'key' => "hl.$name",
'type' => 'param',
'name' => "hl.$name",
'value' => $value
));
}
@Deewde Solarium 6.2.4 was released with updated support for all current highlighting options in Solr.
@mooman's example can now be written natively as:
// create a client instance
$client = new Solarium\Client($adapter, $eventDispatcher, $config);
// get a select query instance
$query = $client->createSelect();
$query->setQuery('memory');
// get highlighting component and apply settings
$hl = $query->getHighlighting();
$hl->setMethod($hl::METHOD_UNIFIED);
$hl->setTagPrefix('<strong>');
$hl->setTagPostfix('</strong>');
$hl->setDefaultSummary(true);
$hl->setOffsetSource($hl::OFFSETSOURCE_ANALYSIS);
A full overview of the supported options can be found in the Solarium documentation.
The new Unified Hightlighter has been added in Solr 6.5.0, which Solarium can't use yet.