Problem/Motivation

The current event subscriber has a hard coded ranking/query implementation. It would be ideal to instead call a custom plugin that handles this instead so developers can implement their own ranking/querying because it will vary site to site. The plugin could be a setting at the index level.

The current implementation can serve as the initial plugin, an example:

/**
 * Pure vector search ranker.
 */
#[SolrRanker(
  id: 'pure_vector',
  label: new TranslatableMarkup('Pure Vector'),
)]
class PureVector extends SolrRankerPluginBase {

  /**
   * {@inheritdoc}
   */
  public function applyRanking(SolariumQueryInterface $query, string $solr_field, int $top_k, array $vectors): SolariumQueryInterface {
    return $query->setQuery('{!knn f=' . $solr_field . ' topK=' . $top_k . '}[' . implode(', ', $vectors[0]) . ']');
  }

}
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

kevinquillen created an issue. See original summary.

kevinquillen’s picture

Title: Create a plugin manager for creating rankings. » Create a plugin manager for handling query modifications/rankings.

kevinquillen’s picture

This merge introduces a new interface and plugin manager as well as moves some of the settings from the processor to the index. A starter plugin is included (PureVector) - from here others are able to develop their own manipulations to fit the use cases they need. There is no real way to solve every users needs in terms of ranking and quality, so this puts the power in their hands to develop around.

kevinquillen’s picture

Status: Active » Fixed

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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