Spellcheck suggestions
======================
``Spellcheck suggestions`` use Solr's SpellCheck component to provide inline query suggestions based on other, similar, terms.
This could be useful to provide the "did you mean" alternative to use when the search returns no results.
.. note::
This feature is available only with the Solr search engine.
1. Activation
~~~~~~~~~~~~~
In order to activate this feature, Solr has to be properly configured. First we need to create a new field type and then a new field of this type for spellcheck suggestions. Then we need to copy all textual fields to it.
solr/custom-fields-types.xml additions:
.. code-block:: xml
Then we need to set-up the SpellCheck component. It should already exist in solrconfig.xml but it might not be properly configured. Example configuration:
solr/solrconfig.xml additions
.. code-block:: xml
text_general
default
solr.IndexBasedSpellChecker
spellcheck
org.apache.lucene.search.spell.LevensteinDistance
true
./spellchecker
0.7
.0001
In order to get suggestions during search, we need to tell our select request handler to use the previously configured SpellCheck component.
Example request handler configuration:
.. code-block:: xml
explicit
10
default
on
true
10
5
5
true
true
10
5
spellcheck
At last, our fulltext search criterion has to implement the ``Netgen\IbexaSearchExtra\API\Values\Content\Query\Criterion\FulltextSpellcheck`` interface.
Here's the example of a criterion which extends Ibexa CMS fulltext criterion and implements the required interface:
.. code-block:: php
query = $this->value;
$spellcheckQuery->count = 10;
return $spellcheckQuery;
}
}
Once activated, you will get the spellcheck suggestions in SearchResult object.