Hello,
I'm using Search API attachments to search in my files, with a Solr hosting. The Solr search on fields (like title) is working.

After enabling the module, I've added the following config on config/search/search_api_attachments:
Extraction method: Solr Extractor
Solr server: 'my solr server'
Tika path: update/extract (default)

After submit I get the following error:

The website encountered an unexpected error. Please try again later.
Error: Call to undefined method Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend::getSolrConnection() in Drupal\search_api_attachments\Plugin\search_api_attachments\SolrExtractor->extract() (line 79 of modules/contrib/search_api_attachments/src/Plugin/search_api_attachments/SolrExtractor.php).
Drupal\search_api_attachments\Plugin\search_api_attachments\SolrExtractor->extract(Object) (Line: 159)
Drupal\search_api_attachments\Form\TextExtractorFormSettings->submitForm(Array, Object)
call_user_func_array(Array, Array) (Line: 111)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 51)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 583)
Drupal\Core\Form\FormBuilder->processForm('search_api_attachments_admin_form', Array, Object) (Line: 314)
Drupal\Core\Form\FormBuilder->buildForm('search_api_attachments_admin_form', Object) (Line: 74)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array) (Line: 144)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 64)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 652)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Comments

simon_h created an issue. See original summary.

dietr_ch’s picture

Status: Active » Needs review
StatusFileSize
new3.17 KB

Hi

I figured the search_api_solr API changed so that it is no longer possible to directly work with the Solarium Client object. Search API Solr now uses SolrConnector plugins that wrap around the Client. You have to implement a custom connector plugin that implements createExtract(), because that's not available in the standard connector. Then the calling code needs to be adjusted to call $backend->getSolrConnector() instead of $backend->getSolrConnection().

Attached is a patch that implements an ExtractingSolrConnector and changes the calling code. You need to edit your Solr connection and change the connector to "Extracting". Then, reconfigure Search API attachments. (If the connector is not changed, the module will not list the Solr server at all.)

Dietrich

acrosman’s picture

Maybe I'm missing something but the problem with this approach is that it seems to mean that the there will need to be two versions of all the Solr connectors: one with extract and one without. Seems like a better approach (for this and potentially other purposes) would be to submit a patch for the main SolrConnectorPluginBase to a generic getQuery() in addition to getSelectQuery() and getUpdateQuery()

mkalkbrenner’s picture

Version: 8.x-1.0-alpha4 » 8.x-1.x-dev
Status: Needs review » Needs work

I second @acrosman. It's a bad approach to have a dedicated connector here.
We have two options:

  • extend the connector interface within search_api_solr to cover the use-case here
  • just use Solarium to create the queries you need and call $response = $connector->execute($query);

To decide what's the best solution I'll have to review Search API attachments first ...

acrosman’s picture

I've opened an issue Search API Solr Search as a feature request to add the generic getQuery() as a place to further this discussion on the right module (#2831801: Add support for extract to Connector API).

acrosman’s picture

dietr_ch’s picture

I agree it should be added to the search_api_solr API. Thanks!

Dietrich

acrosman’s picture

Now that #2831801: Add support for extract to Connector API is resolved this issue should be resolved using the getExtractQuery() method that was added. If no one gets there first I'll try to get a patch pulled together soon.

ekes’s picture

StatusFileSize
new838 bytes

This is all I changed to test it.

ekes’s picture

Status: Needs work » Needs review
mkalkbrenner’s picture

Status: Needs review » Closed (duplicate)
Related issues: +#2862528: Solr Extractor causes Error with wrong method call