You are here

public static function ExcludeSourceFields::supportsIndex in Elasticsearch Connector 8.6

Same name and namespace in other branches
  1. 8.7 src/Plugin/search_api/processor/ExcludeSourceFields.php \Drupal\elasticsearch_connector\Plugin\search_api\processor\ExcludeSourceFields::supportsIndex()
  2. 8.5 src/Plugin/search_api/processor/ExcludeSourceFields.php \Drupal\elasticsearch_connector\Plugin\search_api\processor\ExcludeSourceFields::supportsIndex()

Checks whether this processor is applicable for a certain index.

This can be used for hiding the processor on the index's "Filters" tab. To avoid confusion, you should only use criteria that are more or less constant, such as the index's datasources. Also, since this is only used for UI purposes, you should not completely rely on this to ensure certain index configurations and at least throw an exception with a descriptive error message if this is violated on runtime.

Parameters

\Drupal\search_api\IndexInterface $index: The index to check for.

Return value

bool TRUE if the processor can run on the given index; FALSE otherwise.

Overrides ProcessorPluginBase::supportsIndex

File

src/Plugin/search_api/processor/ExcludeSourceFields.php, line 63

Class

ExcludeSourceFields
Plugin annotation @SearchApiProcessor( id = "exclude_source_fields", label = @Translation("Exclude source fields"), description = @Translation("Exclude certain source fields from search results"), stages = { "preprocess_query" = -20 } )

Namespace

Drupal\elasticsearch_connector\Plugin\search_api\processor

Code

public static function supportsIndex(IndexInterface $index) {
  $backend = $index
    ->getServerInstance()
    ->getBackend();
  return $backend instanceof SearchApiElasticsearchBackend;
}