Closed (fixed)
Project:
Search API Solr
Version:
8.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
28 May 2016 at 08:05 UTC
Updated:
31 Jan 2019 at 20:39 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
mkalkbrennerComment #3
damontgomery commentedI believe I have a start for a solution here. It's definitely not completed and it can't be merged without an upgrade path for people, but I wanted to get this moving in case someone else can jump in.
Please see patch for change. The patch updates the Search API backend to add a 'spellcheck.dictionary' parameter to the Solr query. This is necessary to tell the system which Solr spellcheck system to use. I used the configuration already present to tell if the site wants to search per language. Another one might make sense, but this seems to work. I also am not clear how the query languages are intended to work. If multiple are present, we need to pick one for spellcheck. I select the first. I'm not sure if there are any cases when there wouldn't be a language, so that might need to be addressed as well.
With the patch, you also need to update a few configuration files.
Make / edit a solrconfig_extra.xml
This defines which spellcheckers should exist.
Next, you must add an extra field type per language in schema_extra_types.xml. The reasoning behind this is that if you use the same field types as the normal fields, you will get suggestions that are stemmed. For example, "maternity" is stemmed to "matern". We don't want to suggest someone enter the search term "matern" if they spell "maternity" wrong like "meternite".
Below is my full file for reference.
Next, we need to dynamically fill these fields. You need to update schema_extra_fields.xml. The full file is here for reference.
To test this, you'll need to update your schema_extra_fields.xml, schema_extra_types.xml and solrconfig_extra.xml files, reload the Solr configuration for the core, delete all the data on the core, and reindex the content.
Comment #4
damontgomery commentedChanging status to Feature request and needs work.
Comment #5
damontgomery commentedMy previous patch produced a PHP error about references. This one doesn't. :)
Comment #6
mkalkbrennerYou're moving into the right direction :-)
But Search API Multilingual Solr Search has a concept to dynamically generate the extra xml files and to dynamically modify schema.xml and solrconfig.xml according to the languages active in your drupal instance.
All this magic happens in Drupal\search_api_solr_multilingual\Controller\SolrFieldTypeListBuilder.
So the missing part is to extend the patch to generate the modifications to the xml files you listed in #3.
Comment #7
mkalkbrennerThe implementation should now be like the new Suggester.
Comment #8
mkalkbrennerComment #9
mkalkbrennerI'm working on it:
Comment #10
mkalkbrennerStill WIP, but already a big patch ;-)
Comment #11
mkalkbrennerHere's the final patch.
To fill a spellcheck directory you need to add "Spellcheck" fields to your index, just like the Suggesters in 8.x-2.x.
Comment #14
mpp commented+ * Re-install language-specific field types to enable the new spellcheckers.
Comment #15
mkalkbrennertypo fixed in my repro