Skip to main content

Having Drupal Solr Search APi running, I thought adding synonyms to the mix would be a smooth process.

 

Install synonym module

I cam across a synonym module created by Jens Beltofte - Search API Synonym.  Working on a Drupal 9.3.x installation, this module needs to be accessed via Git Search API Synonym,

There are lots of great tips as you work through the installation, depending on what version of Drupal and Drush you are using.

 

Drush commands

Once you have worked through the steps, you can run the command

drush search-api-synonym:export

However, doing so and you will hit and plugin error.  A little further in Jens notes, and you'll see the necessary add-on

[COMMAND] --plugin=solr --langcode=en

Replacing [COMMAND] with the drush command above.

drush search-api-synonym:export --plugin=solr --langcode=en

 

Errors

Command "search-api-synonym-export" is not defined

If you get an error Command "search-api-synonym-export" is not defined.  As the error states, that is due to the use of the last dash.  Instead needs to be a colon.

drush search-api-synonym:export --plugin=solr --langcode=en

 

The file permissions could not be set on public://synonyms

Starting synonym export....
 [error]  The file permissions could not be set on public://synonyms.
 [error]  The file permissions could not be set on public://synonyms.
 [error]  The specified file 'temporary://fileomBRbX' could not be copied because the destination directory 'public://synonyms' is not properly configured. This may be caused by a problem with file or directory permissions.

In FileSystem.php line 476:

  The specified file 'temporary://fileomBRbX' could not be copied because the destination directory
  'public://synonyms' is not properly configured. This may be caused by a problem with file or
   directory permissions.

Check the chown and chmod settings.  The settings I used were:

Chown

Check the user for the server.  For me, www-data

sudo chown -R www-data:www-data synonyms
Chmod

I'm not a fan of 777, in this instance anything other than 777 would not get the directory writable.  Something that I'll look further in to.

 

Temporary directory error

[error]  Temporary file 'temporary://filesHN9Hh' could not be created.

Your Drupal configuration will the temporary directory preset to /tmp.  Check on your server that the tmp directory exists at root level.  Second, check the chown is set to your server.  As noted earlier, for me this is www.data.

sudo chown -R www-data:www-data tmp

 

Related articles

Andrew Fletcher22 Jan 2025
Removing a missing module in Drupal
Occasionally, a Drupal site may display a warning about a module being "Missing or invalid." This issue occurs when a module is marked as installed in the configuration but is no longer present in the file system. A common example is the `fakeobjects` module, which is associated with CKEditor 4 and...