I tried to configure search_api_attachments with Solr Extractor as the extraction method of choice.
After configuring everything correctly (using the same configuration as with a drupal 7 instance, where everything worked), I get the following error:

AH01071: Got error 'PHP message: Error: Call to undefined method Drupal\\search_api_solr\\Plugin\\search_api\\backend\\SearchApiSolrBackend::getSolrConnection() in /var/www/drupalvm/drupal/docroot/modules/contrib/search_api_attachments/src/Plugin/search_api_attachments/SolrExtractor.php on line 73 #0 /var/www/drupalvm/drupal/docroot/modules/contrib/search_api_attachments/src/Plugin/search_api/processor/FilesExtrator.php(213): Drupal\\search_api_attachments\\Plugin\\search_api_attachments\\SolrExtractor->extract(Object(Drupal\\file\\Entity\\File)) #1 /var/www/drupalvm/drupal/docroot/modules/contrib/search_api_attachments/src/Plugin/search_api/processor/FilesExtrator.php(185): Drupal\\search_api_attachments\\Plugin\\search_api\\processor\\FilesExtrator->extractOrGetFromCache(Object(Drupal\\file\\Entity\\File), Object(Drupal\\search_api_attachments\\Plugin\\search_api_attachments\\SolrExtractor)) #2 /var/www/drupalvm/drupal/docroot/modules/contrib/search_api/src/Item/Item.php(245): Drupal\\search_api_attachments\\Plugin\\search_api\\processor\\FilesExtrato...

Now the class Drupal\\search_api_solr\\Plugin\\search_api\\backend\\SearchApiSolrBackend does contain a method called "getSolrConnector" but does not contain a method called "getSolrConnection". Is this a simple typo?

Either way, I can't use the Solr Extractor configuration at the moment.

Comments

yeldiR created an issue. See original summary.

izus’s picture

I don't think it's a typo but probabely a modification in search_api_solr that was not yet detected and changed in search_api_attachments yet.
if you debugged it locally, please attach a patch here so that we share the correction
Thanks

michaellander’s picture

Status: Active » Needs review
StatusFileSize
new838 bytes

This patch should do it. You'll also need the patch from #2831801: Add support for extract to Connector API.

mkalkbrenner’s picture

Status: Needs review » Reviewed & tested by the community

At least the patch in #3 leverages the current API of Search API Solr 8.x-1.0-beta2.

We now have a test for extraction as well:

  /**
   * Test tika extension PDF extraction.
   */
  public function testExtract() {
    /** @var \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend $backend */
    $backend = Server::load($this->serverId)->getBackend();
    // Initialise the Client.
    $client = $backend->getSolrConnector();
    // Create the Query.
    $query = $client->getExtractQuery();
    // setExtractOnly is only available in solarium 3.3.0 and up.
    $query->setExtractOnly(TRUE);
    $filepath = drupal_get_path('module', 'search_api_solr_test') . '/assets/test_extraction.pdf';
    $query->setFile($filepath);
    // Execute the query.
    $result = $client->extract($query);
    $response = $result->getResponse();
    $json_data = $response->getBody();
    $array_data = Json::decode($json_data);
    // $array_data contains json array with two keys : [filename] that contains
    // the extracted text we need and [filename]_metadata that contains some
    // extra metadata.
    $xml_data = $array_data[$filepath];
    $this->assertContains('The extraction seems working!', $xml_data);
  }

izus’s picture

Status: Postponed » Closed (duplicate)

The issue mentionned in #5 was merged