Jump to content

Extension:SphinxSearch/Windows install

From mediawiki.org

Step 1 - Install Sphinx

[edit]

The first step when installing [1] Sphinx on Windows is to extract everything from the .zip[2] file you have downloaded[3] (such as sphinx-0.9.9-win32.zip or sphinx-0.9.9-win32-pgsql.zip if you need PostgresSQL support as well.) into a folder.

For the remainder of this guide, we will assume that the folders are unzipped into C:\Sphinx, so that searchd.exe can be found in C:\Sphinx\bin\searchd.exe. If you decide to use a different location for the folders or configuration file, please change it accordingly.

Other tutorials

[edit]

Step 2 - Configure Sphinx

[edit]
  1. Open the extension archive (e.g. SphinxSearch-trunk-r97051.tar.gz) and extract sphinx.conf to the Sphinx folder (C:\Sphinx).
  2. Edit the contents of C:\Sphinx\sphinx.conf. Look for sql_db, sql_user, sql_pass, path, log, query_log and pid_file variables.
    Create the paths as necessary. Make sure you use backslashes (\) instead of forward slashes (/).
  3. Don't forget to add a binlog_path = line (that points to a real folder) in the searchd section of C:\Sphinx\sphinx.conf to make sure that the service starts successfully in Windows.
  4. Add the line compat_sphinxql_magics = 0 to the searchd section of C:\Sphinx\sphinx.conf to avoid "WARNING: compat_sphinxql_magics=1 is deprecated" as of SphinxSearch 2.0.1-beta. (Note: As of 2.2.1 Beta [1] this feature was removed and including this line will result in an error).
Configuration sphinx.conf file

Step 3 - Run Sphinx Indexer

[edit]
Running an incremental indexing process in command shell mode

Run the sphinx indexer to prepare for searching:

C:\Sphinx\bin\indexer --config C:\Sphinx\sphinx.conf --all

Once again, make sure to replace the paths to match your installation. This process is actually pretty fast, but clearly depends on how large your wiki is. Just be patient and watch the screen for updates.

If you put sphinx.conf in C:\Sphinx\bin instead of in C:\Sphinx (see Step 2), the indexer command does not need the --config option because it defaults to the current folder:
C:\Sphinx\bin> indexer --all

Step 4 - Test Out Sphinx

[edit]
Actual search process from Mediawiki displayed in command shell mode

When the indexer is finished, test that sphinx searching is actually working:

C:\Sphinx\bin\search --config C:\Sphinx\sphinx.conf "search string"

You will see the result stats immediately (Sphinx is FAST.) Note that the article data you see at this point comes from the sql_query_info in sphinx.conf file. In the extension we can get to the actual article content because we have text old_id available as an extra attribute. It would be slow to fetch article content on the command line (we would have to join page, revision, and text tables,) so we just fetch page_title and page_namespace at this point.

If you put sphinx.conf in C:\Sphinx\bin instead of in C:\Sphinx (see Step 2), the search command does not need the --config option because it defaults to the current folder:
C:\Sphinx\bin> search "search string"

Note: The search.exe program (CLI search) is for testing and debugging purposes only; it is NOT intended for production use. The better options are to use SphinxAPI or SphinxQL.

Step 5 - Start Sphinx Daemon

[edit]

To create the windows service... Note Note: the --config option cannot be omitted here by putting sphinx.conf in the C:\Sphinx\bin\ folder.

C:\Sphinx\bin\searchd.exe --install --config C:\Sphinx\sphinx.conf --servicename SphinxSearch

Start the service

c:\>  sc start SphinxSearch

If it fails:

  • Double check your sphinx.conf file. Make sure the paths are set properly in the searchd section.
  • If the error is FATAL: failed to open 'C:\Wiki\Sphinx\sphinx-2.0.9-release-win32\binlog/binlog.lock': 2 'No such file or directory', then manually create the \binlog folder in the Sphinx install location.
  • If the error is FATAL: OpenSCManager() failed: code=5, error=Access is denied., then run the command prompt with Administrator privileges.

To uninstall the windows service:

C:\WINDOWS\system32> C:\Sphinx\bin\searchd.exe --delete --servicename SphinxSearch

Step 6 - Configure Incremental Updates

[edit]

Use the Windows Task Scheduler, found under Accessories | System Tools | Scheduled Tasks

Create two jobs. One to run once a day and one to run as needed for incremental updates. If you use the scheduler there will not be any command pop ups.

If you get "ERROR: index 'wiki_main': column number 1 has no name." when trying to index, copy libmysql.dll from MySQL 5.0.37 into Sphinx bin directory. For some reason 5.1 version does not work with Sphinx on Windows.

Incremental Update and Windows Task Scheduler

[edit]

As for the index update the windows task scheduler has to run the indexer.exe therefore one solution to avoid unnecessary command pop up in Windows is:

  1. Create a batch file C:\Sphinx\wiki_main.bat that contains
    C:\Sphinx\bin\indexer.exe --quiet --config C:\Sphinx\sphinx.conf wiki_main --rotate
  2. Create another batch file C:\Sphinx\wiki_incremental.bat that contains
    C:\Sphinx\bin\indexer.exe --quiet --config C:\Sphinx\sphinx.conf wiki_incremental --rotate
  3. Using the help of Invisible Batch File and create a C:\Sphinx\invisible.vbs file that contains
    CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False
    this will help to set the batch file invisible
  4. After this the task scheduler can be run with a command like
    %windir%\system32\wscript.exe "C:\Sphinx\invisible.vbs" "C:\Sphinx\wiki_incremental.bat"

Step 7 - Extension Preparation - SphinxSearch Folder

[edit]

See Step 7 - Extension Preparation - SphinxSearch Folder

Step 8.1 - Extension Preparation - Sphinx PHP API

[edit]

See Step 8.1 - Extension Preparation - Sphinx PHP API

Step 8.2 - Extension Installation - PHP Files

[edit]

See Step 8.2 - Extension Installation - PHP Files

Step 9 - Extension Installation - Local Settings

[edit]

See Step 9 - Extension Installation - Local Settings

Troubleshooting

[edit]

Problems and issues of a more general nature can be found on the troubleshooting page, otherwise you might find help on the talk page.

Notes

[edit]
  1. Some information have been copied from http://sphinxsearch.com/docs/current.html#installation and modified where appropriate
  2. Use Windows Explorer in Windows XP and or any other freeware package like 7Zip to open the archive.
  3. See http://sphinxsearch.com/downloads/