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
Comment #2
dietr_ch commentedHi
I figured the search_api_solr API changed so that it is no longer possible to directly work with the Solarium
Clientobject. Search API Solr now usesSolrConnectorplugins that wrap around theClient. You have to implement a custom connector plugin that implementscreateExtract(), 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
ExtractingSolrConnectorand 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
Comment #3
acrosmanMaybe 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 togetSelectQuery()andgetUpdateQuery()Comment #4
mkalkbrennerI second @acrosman. It's a bad approach to have a dedicated connector here.
We have two options:
$response = $connector->execute($query);To decide what's the best solution I'll have to review Search API attachments first ...
Comment #5
acrosmanI'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).
Comment #6
acrosmanComment #7
dietr_ch commentedI agree it should be added to the search_api_solr API. Thanks!
Dietrich
Comment #8
acrosmanNow 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.Comment #9
ekes commentedThis is all I changed to test it.
Comment #10
ekes commentedComment #11
mkalkbrenner