Extension:SphinxSearch/Search suggestions

From MediaWiki.org
Jump to: navigation, search

Latest SVN build has improved search suggestions for SphinxMWSearch - using enchant library and a script that creates a "dictionary" based on the frequency of words in your wiki (so it will never suggest a word that is not actually in the wiki.) I decided to use enchant because direct support for aspell/pspell is being dropped from PHP (at least on Windows) and I could not even install them on my box with php 5.3.

To try it, install enchant, run SphinxSearch_setup.php to create a dictionary, and set $wgSphinxSuggestMode to 'enchant'. Without enchant, you can set $wgSphinxSuggestMode to 'soundex' and it will use mysql's SOUNDEX to find wiki articles that sound similar to the search query. Svemir Brkic 15:35, 14 November 2010 (UTC)

Old method is currently still supported, but only via aspell binary, not via pspell extension. Set $wgSphinxSuggestMode to 'aspell' for that. Svemir Brkic 18:49, 7 September 2011 (UTC)

Enchant[edit]

Enchant is a library that provides a generic interface to third-party spell-checking APIs developed by AbiWord.

$wgSphinxSuggestMode = 'enchant';

Create a dictionary[edit]

Execute SphinxSearch_setup.php to create necessary dictionary files sphinx.dic and sphinx.aff.

Using Enchant with PHP on Linux[edit]

You will need to install the php-enchant library package and restart the httpd service to have SphixSearch begin using this feature.

Using Enchant with PHP on Windows[edit]

See information about Using Enchant with PHP on Windows

Soundex[edit]

According to Wikipedia, soundex is a phonetic algorithm for indexing names by sound. MySQL[1] uses soundex as function to determine and compare two strings that sound almost the same and should return identical soundex strings.

$wgSphinxSuggestMode = 'soundex';

Aspell[edit]

$wgSphinxSuggestMode = 'aspell';

When using the personal dictionary, it is not just a list of words. It needs to have a header line. http://aspell.net/man-html/Format-of-the-Personal-and-Replacement-Dictionaries.html

For example:

personal_ws-1.1 en 0
AwesomeCompanyName
quasirhombicosidodecahedron

This could be a sample Windows aspell configuration:

$wgSphinxSuggestMode = 'aspell';
$wgSphinxSearchAspellPath = "C:\Program Files\Aspell\bin\aspell.exe";
$wgSphinxSearchPersonalDictionary = "D:\Inetpub\web\wiki\sphinx\CustomWords.en.pws";