class SearchApiSolrAnySchemaBackend in Search API Solr 8.2
A read-only backend for any non-drupal schema.
Plugin annotation
@SearchApiBackend(
id = "search_api_solr_any_schema",
label = @Translation("Any Schema Solr"),
description = @Translation("Read-only connection to any Solr server.")
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\search_api\Plugin\HideablePluginBase implements HideablePluginInterface
- class \Drupal\search_api\Plugin\ConfigurablePluginBase implements ConfigurablePluginInterface uses PluginDependencyTrait
- class \Drupal\search_api\Backend\BackendPluginBase implements BackendInterface uses LoggerTrait
- class \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend implements PluginFormInterface, SolrAutocompleteInterface, SolrBackendInterface uses PluginFormTrait, SolrCommitTrait
- class \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrAnySchemaBackend
- class \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend implements PluginFormInterface, SolrAutocompleteInterface, SolrBackendInterface uses PluginFormTrait, SolrCommitTrait
- class \Drupal\search_api\Backend\BackendPluginBase implements BackendInterface uses LoggerTrait
- class \Drupal\search_api\Plugin\ConfigurablePluginBase implements ConfigurablePluginInterface uses PluginDependencyTrait
- class \Drupal\search_api\Plugin\HideablePluginBase implements HideablePluginInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of SearchApiSolrAnySchemaBackend
1 file declares its use of SearchApiSolrAnySchemaBackend
File
- src/
Plugin/ search_api/ backend/ SearchApiSolrAnySchemaBackend.php, line 20
Namespace
Drupal\search_api_solr\Plugin\search_api\backendView source
class SearchApiSolrAnySchemaBackend extends SearchApiSolrBackend {
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
$conf = parent::defaultConfiguration();
$conf['retrieve_data'] = TRUE;
$conf['skip_schema_check'] = TRUE;
return $conf;
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form = parent::buildConfigurationForm($form, $form_state);
$form['advanced']['retrieve_data']['#disabled'] = TRUE;
$form['advanced']['skip_schema_check']['#disabled'] = TRUE;
// @todo force read-only
return $form;
}
/**
* {@inheritdoc}
*/
protected function preQuery(SolariumQueryInterface $solarium_query, QueryInterface $query) {
parent::preQuery($solarium_query, $query);
// Do not alter the query if the index does not use the solr_document
// datasource.
$index = $query
->getIndex();
if (!$index
->isValidDatasource('solr_document')) {
return;
}
// Remove the filter queries that limit the results based on site and index.
$solarium_query
->removeFilterQuery('index_filter');
// Set requestHandler for the query type.
$config = $index
->getDatasource('solr_document')
->getConfiguration();
if (!empty($config['request_handler'])) {
$solarium_query
->addParam('qt', $config['request_handler']);
}
// Set the default query, if necessary and configured.
if (!$solarium_query
->getQuery() && !empty($config['default_query'])) {
$solarium_query
->setQuery($config['default_query']);
}
$backend = $index
->getServerInstance()
->getBackend();
if ($backend instanceof SearchApiSolrBackend) {
$solr_config = $backend
->getConfiguration();
// @todo Should we maybe not even check that setting and use this to
// auto-enable fields retrieval from Solr?
if (!empty($solr_config['retrieve_data'])) {
$fields_list = [];
foreach ($backend
->getSolrFieldNames($index) as $solr_field_name) {
$fields_list[] = $solr_field_name;
}
$extra_fields = [
'language_field',
'label_field',
'url_field',
];
foreach ($extra_fields as $config_key) {
if (!empty($config[$config_key])) {
$fields_list[] = $config[$config_key];
}
}
$solarium_query
->setFields(array_unique($fields_list));
}
}
}
/**
* {@inheritdoc}
*/
protected function applySearchWorkarounds(SolariumQueryInterface $solarium_query, QueryInterface $query) {
parent::applySearchWorkarounds($solarium_query, $query);
// Do not modify 'Server index status' queries.
// @see https://www.drupal.org/node/2668852
if ($query
->hasTag('server_index_status')) {
return;
}
// The query builder of Search API Solr Search bases on 'OR' which is the
// default value for solr, too. But a foreign schema could have a
// non-default config for q.op. Therefor we need to set it explicitly if not
// set.
$params = $solarium_query
->getParams();
if (!isset($params['q.op'])) {
$solarium_query
->addParam('q.op', 'OR');
}
}
/**
* {@inheritdoc}
*/
protected function postQuery(ResultSetInterface $results, QueryInterface $query, $response) {
parent::postQuery($results, $query, $response);
// Do not alter the results if the index does not use the solr_document
// datasource.
$datasources = $query
->getIndex()
->getDatasources();
if (!isset($datasources['solr_document'])) {
return;
}
/** @var \Drupal\search_api_solr\SolrDocumentFactoryInterface $solr_document_factory */
$solr_document_factory = \Drupal::getContainer()
->get('solr_document.factory');
/** @var \Drupal\search_api\Item\Item $item */
foreach ($results
->getResultItems() as $item) {
// Create the typed data object for the Item immediately after the query
// has been run. Doing this now can prevent the Search API from having to
// query for individual documents later.
$item
->setOriginalObject($solr_document_factory
->create($item));
// Prepend each item's itemId with the datasource ID. A lot of the Search
// API assumes that the item IDs are formatted as
// 'datasouce_id/entity_id'. Of course, the ID numbers of external Solr
// documents will not have this pattern and the datasource must be added.
// Reflect into the class to set the itemId.
$reflection = new \ReflectionClass($item);
$id_property = $reflection
->getProperty('itemId');
$id_property
->setAccessible(TRUE);
$id_property
->setValue($item, 'solr_document/' . $item
->getId());
}
}
/**
* Override the default fields that Search API Solr sets up. In particular,
* set the ID field to the one that is configured via the datasource config
* form.
*
* Also, map the index's field names to the original property paths. Search
* API Solr adds prefixes to the paths because it assumes that it has done the
* indexing according to its schema.xml rules. Of course, in our case it
* hasn't and we need it to use the raw paths. Any field machine names that
* have been altered in the field list will have their mapping corrected by
* this step too.
*
* @see \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend::getSolrFieldNames()
*
* {@inheritdoc}
*/
public function getSolrFieldNames(IndexInterface $index, $reset = FALSE) {
// @todo The field name mapping should be cached per index because custom
// queries needs to access it on every query. But we need to be aware of
// datasource additions and deletions.
if (!isset($this->fieldNames[$index
->id()]) || $reset) {
parent::getSolrFieldNames($index, $reset);
// Do not alter mappings if the index does not use the solr_document
// datasource.
$datasources = $index
->getDatasources();
if (isset($datasources['solr_document'])) {
// Set the ID field.
$config = $index
->getDatasource('solr_document')
->getConfiguration();
$this->fieldNames[$index
->id()]['search_api_id'] = $config['id_field'];
$this->fieldNames[$index
->id()]['search_api_language'] = $config['language_field'];
/** @var \Drupal\search_api\Item\FieldInterface[] $index_fields */
$index_fields = $index
->getFields();
// Re-map the indexed fields.
foreach ($this->fieldNames[$index
->id()] as $raw => $name) {
// Ignore the Search API fields.
if (strpos($raw, 'search_api_') === 0 || empty($index_fields[$raw]) || $index_fields[$raw]
->getDatasourceId() !== 'solr_document') {
continue;
}
$this->fieldNames[$index
->id()][$raw] = $index_fields[$raw]
->getPropertyPath();
}
}
}
// Let modules adjust the field mappings.
$this->moduleHandler
->alter('search_api_solr_field_mapping', $index, $this->fieldNames[$index
->id()]);
return $this->fieldNames[$index
->id()];
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BackendPluginBase:: |
protected | property |
The messenger. Overrides MessengerTrait:: |
|
BackendPluginBase:: |
protected | property | The server this backend is configured for. | |
BackendPluginBase:: |
protected | property | The backend's server's ID. | |
BackendPluginBase:: |
public | function |
Adds a new index to this server. Overrides BackendSpecificInterface:: |
2 |
BackendPluginBase:: |
public | function | Retrieves the fields helper. | |
BackendPluginBase:: |
public | function | Retrieves the messenger. | |
BackendPluginBase:: |
public | function |
Retrieves the server entity for this backend. Overrides BackendInterface:: |
|
BackendPluginBase:: |
protected | function | Creates dummy field objects for the "magic" fields present for every index. | 1 |
BackendPluginBase:: |
public | function |
Reacts to the server's creation. Overrides BackendInterface:: |
1 |
BackendPluginBase:: |
public | function |
Notifies the backend that its configuration was updated. Overrides BackendInterface:: |
2 |
BackendPluginBase:: |
public | function |
Notifies the backend that the server is about to be deleted. Overrides BackendInterface:: |
1 |
BackendPluginBase:: |
public | function |
Notifies the backend that its configuration is about to be updated. Overrides BackendInterface:: |
1 |
BackendPluginBase:: |
public | function | Sets the fields helper. | |
BackendPluginBase:: |
public | function |
Sets the messenger. Overrides MessengerTrait:: |
|
BackendPluginBase:: |
public | function |
Sets the server entity for this backend. Overrides BackendInterface:: |
|
BackendPluginBase:: |
protected | function | Verifies that the given condition operator is valid for this backend. | |
BackendPluginBase:: |
public | function |
Implements the magic __sleep() method. Overrides DependencySerializationTrait:: |
1 |
BackendPluginBase:: |
public | function |
Implements the magic __wakeup() method. Overrides DependencySerializationTrait:: |
1 |
ConfigurablePluginBase:: |
protected | function | Calculates and adds dependencies of a specific plugin instance. | |
ConfigurablePluginBase:: |
public | function |
Gets this plugin's configuration. Overrides ConfigurableInterface:: |
|
ConfigurablePluginBase:: |
public | function |
Returns the plugin's description. Overrides ConfigurablePluginInterface:: |
|
ConfigurablePluginBase:: |
protected | function | Calculates and returns dependencies of a specific plugin instance. | |
ConfigurablePluginBase:: |
public | function |
Returns the label for use on the administration pages. Overrides ConfigurablePluginInterface:: |
|
ConfigurablePluginBase:: |
protected | function | Wraps the module handler. | |
ConfigurablePluginBase:: |
public | function |
Informs the plugin that some of its dependencies are being removed. Overrides ConfigurablePluginInterface:: |
5 |
ConfigurablePluginBase:: |
protected | function | Wraps the theme handler. | |
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencyTrait:: |
protected | property | The object's dependencies. | |
DependencyTrait:: |
protected | function | Adds multiple dependencies. | |
DependencyTrait:: |
protected | function | Adds a dependency. | |
HideablePluginBase:: |
public | function |
Determines whether this plugin should be hidden in the UI. Overrides HideablePluginInterface:: |
1 |
LoggerTrait:: |
protected | property | The logging channel to use. | |
LoggerTrait:: |
public | function | Retrieves the logger. | |
LoggerTrait:: |
protected | function | Logs an exception. | |
LoggerTrait:: |
public | function | Sets the logger. | |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
PluginDependencyTrait:: |
protected | function | Calculates and adds dependencies of a specific plugin instance. Aliased as: traitCalculatePluginDependencies | 1 |
PluginDependencyTrait:: |
protected | function | Calculates and returns dependencies of a specific plugin instance. Aliased as: traitGetPluginDependencies | |
PluginDependencyTrait:: |
protected | function | Wraps the module handler. Aliased as: traitModuleHandler | 1 |
PluginDependencyTrait:: |
protected | function | Wraps the theme handler. Aliased as: traitThemeHandler | 1 |
PluginFormTrait:: |
public | function | Form submission handler. Aliased as: traitSubmitConfigurationForm | 7 |
SearchApiSolrAnySchemaBackend:: |
protected | function |
Apply workarounds for special Solr versions before searching. Overrides SearchApiSolrBackend:: |
|
SearchApiSolrAnySchemaBackend:: |
public | function |
Form constructor. Overrides SearchApiSolrBackend:: |
|
SearchApiSolrAnySchemaBackend:: |
public | function |
Gets default configuration for this plugin. Overrides SearchApiSolrBackend:: |
|
SearchApiSolrAnySchemaBackend:: |
public | function |
Override the default fields that Search API Solr sets up. In particular,
set the ID field to the one that is configured via the datasource config
form. Overrides SearchApiSolrBackend:: |
|
SearchApiSolrAnySchemaBackend:: |
protected | function |
Allow custom changes before search results are returned for subclasses. Overrides SearchApiSolrBackend:: |
|
SearchApiSolrAnySchemaBackend:: |
protected | function |
Allow custom changes before sending a search query to Solr. Overrides SearchApiSolrBackend:: |
|
SearchApiSolrBackend:: |
protected | property | The data type helper. | |
SearchApiSolrBackend:: |
protected | property | Metadata describing fields on the Solr/Lucene index. | |
SearchApiSolrBackend:: |
protected | property |
Overrides BackendPluginBase:: |
|
SearchApiSolrBackend:: |
protected | property | The language manager. | |
SearchApiSolrBackend:: |
protected | property | The module handler. | |
SearchApiSolrBackend:: |
protected | property | The Solarium query helper. | |
SearchApiSolrBackend:: |
protected | property | A config object for 'search_api_solr.settings'. | |
SearchApiSolrBackend:: |
protected | property | ||
SearchApiSolrBackend:: |
protected | property | The backend plugin manager. | |
SearchApiSolrBackend:: |
protected | function | Helper method for indexing. | |
SearchApiSolrBackend:: |
protected | function | Adds item language conditions to the condition group, if applicable. | |
SearchApiSolrBackend:: |
protected | function | Allow custom changes before converting a SearchAPI query into a Solr query. | 1 |
SearchApiSolrBackend:: |
protected | function | Applies custom modifications to indexed Solr documents. | 1 |
SearchApiSolrBackend:: |
protected | function | Allow custom changes to the response body before extracting values. | 1 |
SearchApiSolrBackend:: |
public | function |
Allow custom changes to the Solarium Spellcheck autocomplete query. Overrides SolrAutocompleteInterface:: |
|
SearchApiSolrBackend:: |
public | function |
Allow custom changes to the Solarium Suggester autocomplete query. Overrides SolrAutocompleteInterface:: |
|
SearchApiSolrBackend:: |
public | function |
Allow custom changes to the Solarium Terms autocomplete query. Overrides SolrAutocompleteInterface:: |
|
SearchApiSolrBackend:: |
public static | function | Handles switching the selected Solr connector plugin. | |
SearchApiSolrBackend:: |
public | function | Builds the backend-specific configuration form. | |
SearchApiSolrBackend:: |
public | function |
Calculates dependencies for the configured plugin. Overrides ConfigurablePluginBase:: |
|
SearchApiSolrBackend:: |
public static | function |
Creates an instance of the plugin. Overrides BackendPluginBase:: |
|
SearchApiSolrBackend:: |
protected | function | Recursively transforms conditions into a flat array of Solr filter queries. | |
SearchApiSolrBackend:: |
protected | function | Create a single search query string. | |
SearchApiSolrBackend:: |
protected | function | Creates an ID used as the unique identifier at the Solr server. | |
SearchApiSolrBackend:: |
protected | function | Create a single search query string. | |
SearchApiSolrBackend:: |
public | function |
Deletes all the items from the index. Overrides BackendSpecificInterface:: |
|
SearchApiSolrBackend:: |
public | function |
Deletes the specified items from the index. Overrides BackendSpecificInterface:: |
|
SearchApiSolrBackend:: |
public | function |
Executes a graph streaming expression. Overrides SolrBackendInterface:: |
|
SearchApiSolrBackend:: |
public | function |
Executes a streaming expression. Overrides SolrBackendInterface:: |
|
SearchApiSolrBackend:: |
public | function |
Extract a file's content using tika within a solr server. Overrides SolrBackendInterface:: |
|
SearchApiSolrBackend:: |
protected | function | Extracts facets from a Solarium result set. | |
SearchApiSolrBackend:: |
protected | function | Extract results from a Solr response. | |
SearchApiSolrBackend:: |
protected | function | ||
SearchApiSolrBackend:: |
public | function |
Overrides SolrBackendInterface:: |
|
SearchApiSolrBackend:: |
protected | function | Flattens keys and fields into a single search string. | |
SearchApiSolrBackend:: |
public | function | Tries to format given date with solarium query helper. | |
SearchApiSolrBackend:: |
protected | function | Format a value for filtering on a field of a specific type. | |
SearchApiSolrBackend:: |
protected | function | Get the fields to search for autocomplete terms. | 1 |
SearchApiSolrBackend:: |
protected | function | ||
SearchApiSolrBackend:: |
protected | function | Get the spellcheck suggestions from the autocomplete query result. | |
SearchApiSolrBackend:: |
protected | function | Get the term suggestions from the autocomplete query result. | |
SearchApiSolrBackend:: |
public | function | Implements autocomplete compatible to AutocompleteBackendInterface. | |
SearchApiSolrBackend:: |
protected | function | Get the term suggestions from the autocomplete query result. | |
SearchApiSolrBackend:: |
public | function |
Provides information on additional fields made available by the backend. Overrides BackendPluginBase:: |
|
SearchApiSolrBackend:: |
public | function |
Limits the processors displayed in the UI for indexes on this server. Overrides BackendPluginBase:: |
|
SearchApiSolrBackend:: |
public | function |
Retrieves a Solr document from an search api index item. Overrides SolrBackendInterface:: |
|
SearchApiSolrBackend:: |
public | function |
Retrieves Solr documents from search api index items. Overrides SolrBackendInterface:: |
|
SearchApiSolrBackend:: |
public | function |
Returns the targeted content domain of the server. Overrides SolrBackendInterface:: |
|
SearchApiSolrBackend:: |
protected | function | Serializes a query's conditions as Solr filter queries. | 1 |
SearchApiSolrBackend:: |
protected | function | Extract and format highlighting information for a specific item. | |
SearchApiSolrBackend:: |
public | function |
Returns a ready to use query string to filter results by index and site. Overrides SolrBackendInterface:: |
|
SearchApiSolrBackend:: |
protected | function | Prefixes an index ID as configured. | |
SearchApiSolrBackend:: |
protected | function | Changes the query to a "More Like This" query. | |
SearchApiSolrBackend:: |
protected | function | Computes the cardinality of a complete property path. | |
SearchApiSolrBackend:: |
protected | function |
Don't return the big twm_suggest field. Overrides BackendPluginBase:: |
|
SearchApiSolrBackend:: |
public | function |
Overrides SolrBackendInterface:: |
|
SearchApiSolrBackend:: |
protected | function | Returns all available backend plugins, as an options list. | |
SearchApiSolrBackend:: |
public | function |
Autocompletion suggestions for some user input using Spellcheck component. Overrides SolrAutocompleteInterface:: |
|
SearchApiSolrBackend:: |
public | function |
Autocompletion suggestions for some user input using Suggester component. Overrides SolrAutocompleteInterface:: |
|
SearchApiSolrBackend:: |
public | function |
Returns all features that this backend supports. Overrides BackendPluginBase:: |
|
SearchApiSolrBackend:: |
public | function |
Autocompletion suggestions for some user input using Terms component. Overrides SolrAutocompleteInterface:: |
|
SearchApiSolrBackend:: |
protected | function | Checks if hierarchical properties are nested on an entity-typed property. | |
SearchApiSolrBackend:: |
protected | function | Checks if the recently updated index had any fields changed. | |
SearchApiSolrBackend:: |
public | function |
Indexes the specified items. Overrides BackendSpecificInterface:: |
|
SearchApiSolrBackend:: |
public | function |
Overrides BackendPluginBase:: |
|
SearchApiSolrBackend:: |
protected | function | Checks if a field is (potentially) hierarchical. | |
SearchApiSolrBackend:: |
public | function |
Indicates if the Solr server uses a managed schema. Overrides SolrBackendInterface:: |
1 |
SearchApiSolrBackend:: |
protected | function | Reduces an array of filter queries to an array containing one filter query. | |
SearchApiSolrBackend:: |
public | function |
Removes an index from this server. Overrides BackendPluginBase:: |
|
SearchApiSolrBackend:: |
public | function |
Options on $query prefixed by 'solr_param_' will be passed natively to Solr
as query parameter without the prefix. For example you can set the "Minimum
Should Match" parameter 'mm' to '75%' like this: Overrides BackendSpecificInterface:: |
|
SearchApiSolrBackend:: |
protected | function | Set the spellcheck parameters for the solarium autocomplete query. | |
SearchApiSolrBackend:: |
protected | function | Set the suggester parameters for the solarium autocomplete query. | 1 |
SearchApiSolrBackend:: |
protected | function | Set the term parameters for the solarium autocomplete query. | |
SearchApiSolrBackend:: |
public | function |
Sets the configuration for this plugin instance. Overrides BackendPluginBase:: |
|
SearchApiSolrBackend:: |
protected | function | Helper method for creating the facet field parameters. | 1 |
SearchApiSolrBackend:: |
protected | function | Set the list of fields Solr should return as result. | |
SearchApiSolrBackend:: |
protected | function | Sets grouping for the query. | |
SearchApiSolrBackend:: |
protected | function | Sets the highlighting parameters. | |
SearchApiSolrBackend:: |
protected | function | Adds rpt spatial features to the search query. | |
SearchApiSolrBackend:: |
protected | function | Sets sorting for the query. | |
SearchApiSolrBackend:: |
protected | function | Adds spatial features to the search query. | |
SearchApiSolrBackend:: |
public | function |
Overrides PluginFormInterface:: |
1 |
SearchApiSolrBackend:: |
public | function |
Determines whether the backend supports a given add-on data type. Overrides BackendPluginBase:: |
|
SearchApiSolrBackend:: |
public | function |
Notifies the server that an index attached to it has been changed. Overrides BackendPluginBase:: |
|
SearchApiSolrBackend:: |
public | function |
Overrides PluginFormTrait:: |
1 |
SearchApiSolrBackend:: |
public | function |
Overrides BackendPluginBase:: |
|
SearchApiSolrBackend:: |
public | function |
Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides BackendPluginBase:: |
|
SolrCommitTrait:: |
protected | function | Explicitly sent a commit command to a Solr server. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |