Problem/Motivation
Multilingual websites are throwing the below error when they are not configured to support multilingual Algolia indexes.
The website encountered an unexpected error. Please try again later.AlgoliaSearch\AlgoliaException: Index {MY_INDEX}_en does not exist in AlgoliaSearch\Client->doRequest() (line 1371 of /private/var/www/sites/mskcc_build/vendor/algolia/algoliasearch-client-php/src/AlgoliaSearch/Client.php).
AlgoliaSearch\Client->request(Object, 'POST', '/1/indexes/{MY_INDEX}__en/query', Array, Array, Array, 1, 5, Array) (Line: 619)
AlgoliaSearch\Index->search('*', Array) (Line: 466)
Drupal\search_api_algolia\Plugin\search_api\backend\SearchApiAlgoliaBackend->search(Object) (Line: 468)
Drupal\search_api\Entity\Server->search(Object) (Line: 535)
Drupal\search_api\Query\Query->execute() (Line: 308)
search_api_preprocess_search_api_index(Array, 'search_api_index', Array) (Line: 287)
Proposed resolution
Make multilingual Algolia index support a configuration setting and prevent fatal errors when a multilingual Algolia index is missing.
Remaining tasks
TDB
User interface changes
New configuration settings
API changes
TDB
Data model changes
N/A
Release notes snippet
TDB
| Comment | File | Size | Author |
|---|---|---|---|
| #21 | 3106901-21.patch | 14.56 KB | marijan gudelj |
| #20 | 3106901-20-12-interdiff.txt | 3.21 KB | mbovan |
| #20 | 3106901-20.patch | 15.82 KB | mbovan |
| #12 | 3106901-10.patch | 15.9 KB | jlongbottom |
| #9 | 3106901-9.patch | 15.93 KB | nikunjkotecha |
Issue fork search_api_algolia-3106901
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
nikunjkotechaInitial patch with approach to make suffix optional
@Jacob: Please review updated INSTALL.md and help confirm if this looks OK.
Note: I renamed txt to md to ensure they are better readable.
Comment #3
jrockowitz commented@nikunjkotecha Thank you for responding so quickly. I will review the patch as soon as I have time available.
Comment #4
ben.hamelinJust applied this patch and so far it's working to solve the main indexing issue.
One thing I ran into was when clearing the indexes - was hitting an error because not all the indexes were setup but the loop was trying to clear all of them.
Under the content configuration for the index, we have the language options. I feel like those settings should be respected during the delete items loop. So replacing the getLanguages() output with the configured languages from the content datasource.
Comment #5
benjy commentedSetting back to NW for the last comment, sounds like we haven't handled all places where the language suffix should be taken into account.
Comment #6
nikunjkotechaI've added some of the code formatting fixes and bugs too
Comment #7
nikunjkotechaComment #8
nikunjkotecha> So replacing the getLanguages() output with the configured languages from the content datasource.
Need to check this.
Comment #9
nikunjkotechaUse languages from datasource configuration now.
Comment #11
nikunjkotechaBuild was successful and couldn't find any errors too on the console https://dispatcher.drupalci.org/job/drupal8_contrib_patches/35263/console
Comment #12
jlongbottom commentedPatch works great, however it did not apply cleanly using composer due to differences in the .info file due to extra information added by Drupal.org packaging script.
Here is my patch, which basically just accounts for the extra white space added to the info file.
Comment #13
nikunjkotechaThanks @Justin
Apart from that do you think this can be moved to RTBC?
Comment #14
jlongbottom commentedI was a bit confused why
search_api_autocompleteis now a required dependency after applying the patch. Seems like something that could be configured. Other than that, it seems to work as intended.Comment #15
nikunjkotechaSupport for autocomplete is added in the module and its classes are used, if it won't be there it might break. When checking with drupal-check for code analysis and deprecations I found out it was throwing error for missing classes. This can still stay disabled though but we just need the code to be there so it doesn't break.
Comment #16
kknoer commentedI am still having issues running the latest 2.0.0-alpha1 version of the module.
If I create an index on a multilingual site, one language Spanish, I am unable to open any index in the admin configuration page and I receive the same mentioned error:
I installed the module via:
composer require "drupal/search_api_algolia:^2.0". I have no pending updates and I have cleared all caches.I am trying to get this module upgraded in preparing to upgrade to Drupal 9.
Any ideas?
Comment #17
nikunjkotecha@Keith are you using the patch from this ticket? Without that you will need indexes with language suffix
Comment #18
mbovan commentedThis part contradicts with a required dependency to
search_api_autocomplete. Shall we make it optional as the comments suggests?Is this really needed?
This prevents any inheritance in case there is a need for custom implementation.
I would advise against this change, especially it being done in #3106901: Make language suffix a configuration issue.
Comment #19
mbovan commentedUpdated the affected version.
Comment #20
mbovan commentedUpdates:
Comment #21
marijan gudeljHere is a patch with this fix and also updated the Algolia version to 2.0 found https://www.drupal.org/project/search_api_algolia/issues/3091525.
Without this patch you cannot install new version and apply this fix.
Comment #23
Heisen-blueI've just tested the patch submitted on #20, it works great.
Comment #26
nikunjkotechaComment #27
nikunjkotechaMerged in https://git.drupalcode.org/project/search_api_algolia/-/merge_requests/4 after fixing few issues and also updated readme.
Credits given to all involved in this ticket and https://www.drupal.org/project/search_api_algolia/issues/3091525