Hi all
I have a severe problem with the latest version of apachesolr.
Normally when I search a wrong typed word, for example "spel", the search returned a spell suggestion called "spell" aka "Did you mean" "spell".
But now, the word "spel" is not found and solr return nothing, not even spell suggestions. I think, spell suggestions should be added to the result even if there was no matching word found.
I tried to to find the source of the problem but was not successful until now. Maybe someone has an idea how to resolve this.
Solr: 3.6.2
Drupal 7, Apachesolr 1.2
Solr config 3.x copied over to solr
The spellchecker index works: If I call this url, I get the correct spell suggestion:
localhost:8983/solr/select/?q=spel&spellcheck=true&spellcheck.build=true&version=2.2&spellcheck.extendedResults=true
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | fix-apachesolr_search_build_spellcheck.patch | 1.38 KB | janusman |
| #14 | fix-apachesolr_search_build_spellcheck.patch | 776 bytes | janusman |
Comments
Comment #1
ayalon commentedOk I think, the problem is, that the spellchecker index is never build.
I see, that the spellchecker files in the data folder are empty.
I added the following parameter to the search query:
function mymodule_apachesolr_query_alter(&$query) {
$query->addParam('spellcheck.build', true);
}
With the next query, the spellchecker index was build.
Of cource, the build parameter should only be added once.
I checked the code of the apache solr module and I think, the spellchecker.build parameter is only added if the index is deleted.
But there must be a somewhere a switch that builds the spellchecker index after indexing some documents.
Comment #2
nick_vhapachesolr_search_build_spellcheck is the function. Normally solr builds the spellcheck itself. Any suggestions on how to improve it?
Comment #3
ayalon commentedHi Nick_vh
All my analysis is based on a new solr installation without a data directory. People who have a spellchecker, should delete the whole data directory and then have a look, if it is rebuild. With the latest version, the spellchecker is never built.
I also found the function "apachesolr_search_build_spellcheck" but I think, this function does not work. Because there is a try / catch or because it never gets executed. If you use the "Delete index" function in the UI, the spellchecker never gets deleted.
I made a small module, to manually rebuild the spellchecker index. I wanted to use the code from the function "apachesolr_search_build_spellcheck", but the code throws an error.
The Api has changed:
Code from apachesolr module:
$response = $solr->search('solr', 0, 0, $params);Working code:
$response = $solr->search('solr', $params);I made a custom module, that adds a button to the backend, to rebuild the spellchecker index:
But this is not a real solution. If you add new documents to the index, the spellchecker index will not be updated. I searched for a hook in apache solr but there is only an hook_index_document that is not suitable for rebuilding the spellchecker index.
I searched for a possibility to rebuild the spellcheck index from the solr side but I did not found a solution.
Comment #4
ayalon commentedThe is a possibility to rebuild the spellchecker index on commit:
http://wiki.apache.org/solr/SpellCheckComponent#Building_on_Commits
But I don't see a way how to add this line to the config file:
<str name="buildOnCommit">true</str>There is no configuration available for this.
Comment #5
ayalon commentedOk I got it. It's not in solrconfig.xml, it's in solrconfig_extra.xml...
<str name="buildOnCommit">true</str>You have to add this line to the file, the it works as expected. The index is built on commit. I think this is a severe bug.
Comment #6
WoozyDuck commentedI still have the problem, using Solr 4.2.0 and installed 7.x-1.2 version of this module on Drupal 7.
Your solution didn't help me
Comment #7
pwolanin commentedAh, the past setup was to rebuild the spellcheck index on optimize, and to do that once per day.
Running it per commit can be costly
Comment #8
ayalon commentedHi Peter
If you take the current 7-x1.2 version:
Could you show me, how the spellchecker index is rebuilt once per day? Building on commit might be costly. But I don't see any code, that rebuilds the spellchecker index even once a day. I also noticed this on Acquia search. I have a customer where the spellchecker index is not built.
Comment #9
nick_vhComment #10
nick_vhpwolanin has committed this to the common configs and we should verify if it works as expected and also verify 6.x-3.x
Comment #11
nick_vhComment #12
nick_vhClosing to clean the issue queue a bit
Comment #13
theamoeba commented+1
Comment #14
janusman commentedReopening. Problem from #3 is still present, meaning, deleting the index from the UI does not properly rebuild the spellchecker because of wrong arguments passed to search().
Attached patch has fix.
Comment #15
janusman commentedNew patch, this needed more tweaking.
Comment #17
janusman commentedCommitted.