solariumphp / solarium

PHP Solr client library
Other
933 stars 302 forks source link

Feature Request: Support the new Unified Highlighter #517

Closed Deewde closed 2 years ago

Deewde commented 7 years ago

The new Unified Hightlighter has been added in Solr 6.5.0, which Solarium can't use yet.

A new highlighter named UnifiedHighlighter has been added. You are encouraged to try out the UnifiedHighlighter by setting hl.method=unified and report feedback. It might become the default in 7.0. It's more efficient/faster than the other highlighters, especially compared to the original Highlighter.

mooman commented 6 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
      )); 
    } 
thomascorthals commented 2 years ago

@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.