Extension talk:SphinxSearch

Jump to navigation Jump to search

About this board

The talk page now uses liquid threads, all open messages prior to liquid threads have been converted into a talk subpage and can be found here.
It is recommended to use SphinxSearch 0.8.5 and a recent stable release of Sphinx 2.1. Please bear in mind that this extension only handles the communication between MediaWiki and Sphinx and any specific issues related to the search feature (character sets, ability to search with *, search categories, minimum length on search terms etc.) are handled in Sphinx (see sphinx.conf file) and those questions should be redirected to the Sphinx forum.
The development on this extension is done on a voluntary basis and while this forum provides a platform to share experiences and solutions, it is up to its community members to fill in suggestions.


When seeking help and/or support, you might want to consider to mention your system environment (SphinxSearch Extension version, Sphinx version, MW version etc.) otherwise it might be difficult for people to make appropriate recommendations.

For Windows users and related issues see here, for Linux users and related issues see here, and some advice on how to configure a SQLite setup see here. (talkcontribs)

Line 76 of SphinxMWSearch.php is incorrectly coded.

SearchDatabase class requires an ILoadBalance construct

Without you get error:

SearchDatabase::__construct() must implement interface Wikimedia\\Rdbms\\ILoadBalancer,

        instance of Wikimedia\\Rdbms\\MaintainableDBConnRef given,

        called in /var/www/html/mediawiki/extensions/SphinxSearch/SphinxMWSearch.php on line 76

To fix, change line 76 from wfGetDB( DB_REPLICA ) to wfGetLB( DB_REPLICA )

Reply to "1.34 (possibly newer)"

How to customize advanced search namespaces?

Shmaro38 (talkcontribs)

I am using SphinxSearch 0.9.1 for MediaWiki 1.31 LTS. I am trying to customize the advanced search (searching using namespaces) that is included in my Special:Search page. I have found the following manual for altering the default namespace: Manual:$wgNamespacesToBeSearchedDefault. However, the changes I make on my LocalSettings.php does not seem to be reflecting on the Special:Search page.

Specifically, I have included the following code:

$wgNamespacesToBeSearchedDefault = [NS_HELP => false, ];

in LocalSettings.php to see if it would disable the "Help" namespace from the advanced search, but there was no change to the page.

Is there something I am doing wrong? Please help. I am new to MediaWiki and php in general, hence I understand that I may be missing a big point. Thank you!

Reply to "How to customize advanced search namespaces?"

Sphinx sql_query parameter broken in MW 1.34+

Lavamind (talkcontribs)

If anyone, after upgrading to MW 1.34, is finding out that any recently edited pages disappear completely from the index, fear not. There's a fix.

MediaWiki is changing the manner in which content is referenced in the database. To configure Sphinx to correctly index all pages using the new schema, change the following sphinx.conf parameter:

   sql_query  = SELECT page_id, page_title, page_namespace, page_is_redirect, old_id, old_text FROM page, revision, text WHERE rev_id=page_latest AND old_id=rev_text_id


   sql_query = SELECT page_id, page_title, page_namespace, page_is_redirect, old_id, old_text FROM page, slots, content, text WHERE slots.slot_revision_id=page.page_latest AND content.content_id=slots.slot_content_id AND text.old_id=REPLACE(content.content_address, 'tt:', '')
Reply to "Sphinx sql_query parameter broken in MW 1.34+"

Issues with SphinxSearch in 1.34

2 (talkcontribs)

I upgraded mediawiki to 1.34 and SphinxSearch to the version that matches version 1.34. When I run a search I get this error:

[895083e3cfe4edcfab999700] /testwiki/index.php?search=Celia&title=Spezial%3ASuche&go=Seite ArgumentCountError from line 28 of /srv/www/htdocs/testwiki/extensions/SphinxSearch/SphinxMWSearchResult.php: Too few arguments to function SphinxMWSearchResult::getTextSnippet(), 0 passed in /srv/www/htdocs/testwiki/includes/widget/search/FullSearchResultWidget.php on line 65 and exactly 1 expected

When I took a look at SphinxMWSearchResult.php found that getTextSnippet is expecting the parameter terms

       public function getTextSnippet( $terms ) {

However I found this in the 1.34 release notes.

* SearchResult::getTextSnippet( $terms ) the $terms param is being deprecated

  and should no longer be passed. Search engine implemenations should be

  responsible for carrying relevant information needed for highlighting with

  their own SearchResultSet/SearchResult sub-classes.

Is the error caused by a bug or by a configuration issue?

Lavamind (talkcontribs)
Reply to "Issues with SphinxSearch in 1.34"

When might we expect compatibility with 1.34?

WhitWye (talkcontribs)

Although the download page does offer a version for 1.34, at least in my experience that throws errors after installation, for example "[728f57963e6ba6317d0fee1a] 2020-01-30 15:54:50: Fatal exception of type "ArgumentCountError". To be fair, the page we're discussing here only shows compatibility up through 1.33. Is an update something we should expect soon?

Reply to "When might we expect compatibility with 1.34?"

Sphinx Extension Doesnt work for me

Bsashidh (talkcontribs)

I am new to media wiki and for that matter to any web application development. I was exploring Mediawiki and have installed "MediaWiki 1.18.2" and have attempted to integrate Sphinx search. I have used "Sphinx 2.0.4-release".

The problem I am facing is that I am unable to search through the contents of the pages or the documents embedded in the MediWiki. It is only able to search the Title of the Pages. This is the same irrespective of the "GO" button or the "SEARCH" button. Whereas Through the command in the Sphinx Search, I am able to find all the text. Can someone please help me in debugging this.

MWJames (talkcontribs)

The documentation is quite extensive (compared with other extensions), and it might be that you need to do the setup more than ones to fully understand the implication in how searchd, indexer and SphinxSearch is working together. If you follow the steps outlined in the documentation you should be able get the extension working but it will be hard for anyone to give any guidance as long their are no particular problems to solve.

For example did you do "Step 4 - Test Out Sphinx" to ensure that the infrastructure is setup correctly otherwise if this step fails something is wrong in your configuration and searching within MediaWiki will definitely not work as advertised.

In order to use Sphinx in MediaWiki you have register the extension, see "Step 9 - Extension Installation - Local Settings"

You should also consult the Extension:SphinxSearch/Troubleshooting page.

SphinxSearch and MediaWiki 1.19.0 -- fixed

4 (talkcontribs)

After migraging to MediaWiki 1.19.0 SphinxSearch 0.85 does not work on the Spechial:Search page anymore (no results). The sidebar Search works.

After logging the searchd with --console, you found a message "query error: no such filter attribute 'page_is_redirect'" in the console. I searched this text and found it in 'SphinxMWSearch.php'. I change the line

$cl->SetFilter( 'page_is_redirect', array( 0 ) );


// $cl->SetFilter( 'page_is_redirect', array( 0 ) );

and everything works (for me).

I also change the method 'userHighlightPrefs' to

	public static function userHighlightPrefs() {return array( 2, 75 ); }

because the the definition changed (and I got warning when I activated "$wgShowExceptionDetails" in LocalSettings.php).

I hope this helps others fixing the same problems.

Svemir Brkic (talkcontribs)

Perhaps page_is_redirect is missing in the sphinx.conf? It did not use to be there by default, but in more recent versions you should see it in at least three places in your sphinx.conf, in both sql_query settings, and in one sql_attr_uint setting. After you change the config file, you need to reindex the wiki. (talkcontribs)

Hello Svemir,

thanx, that was the solution.

MWJames (talkcontribs)

During our tests with MW 1.19 / SphinxSearch 0.8.5 we haven't seen any problems and therefore are able to run SphinxSearch 0.8.5 without any changes on MW 1.19. (talkcontribs)

I got tripped up by the use of 'spinxconf' instead of 'sphinxconf' as an option to SphinxSearch_setup.php. The following patch may avoid minor confusion for new users:

--- a/SphinxSearch/SphinxSearch_setup.php   2012-06-04 14:08:10.000000000 -0700
+++ b/SphinxSearch/SphinxSearch_setup.php   2012-06-05 12:59:57.289298038 -0700
@@ -24,7 +24,7 @@
        /* Override parameters setup becuase we do not need some of the default ones */
        protected function addDefaultParams() {
-               $this->addOption( 'spinxconf', 'Location of Sphinx configuration file', true, true );
+               $this->addOption( 'sphinxconf', 'Location of Sphinx configuration file', true, true );
                $this->addOption( 'indexer', 'Full path to Sphinx indexer if not in the path', false, true );
                $this->addOption( 'useindex', 'Sphinx index to use (defaults to wiki_main)', false, true );
                $this->addOption( 'maxwords', 'Maximum number of words to extract (defaults to 10000)', false, true 
@@ -36,7 +36,7 @@
                $max_words = intval( $this->getOption( 'maxwords', 10000 ) );
                $indexer = wfEscapeShellArg( $this->getOption( 'indexer', 'indexer' ) );
                $index = wfEscapeShellArg( $this->getOption( 'useindex', 'wiki_main' ) );
-               $conf = wfEscapeShellArg( $this->getOption( 'spinxconf' ) );
+               $conf = wfEscapeShellArg( $this->getOption( 'sphinxconf' ) );
                $cmd = "$indexer  --config $conf $index --buildstops sphinx.dic $max_words";
                $this->output( wfShellExec( $cmd, $retval ) );
Svemir Brkic (talkcontribs)

Thank you for the fix. MW and extensions are moving from SVN to Git - I will apply and commit your change once all that is done.

Svemir Brkic (talkcontribs)

It seems like its going it be a while before this extension is moved to Git. I made the change in SVN now (revision 115486)

Navication not working for search results

4 (talkcontribs)

I'm installing Sphinx-2.0.4 with the Mediawiki 1.19 with SphinxSearch extension version 0.8.5. I am running on Windows 2008 R2, Apache 2.4.2, MYSQL 5.5.24, and PHP5.4.3.

When I just added sphinx to my wiki and with I do a search for say "conventions" where I know I have pages I get back "Results 1 - 14 of 233" for Conventions but the "View (previous 20 | next 20) are in black and can't be selected. How do I fix this. Users need to get to the next batch of 20 pages. Why is it only showing 14 (1 -14 off 233)? This is for most searches I have had a couple searches the result in "Results 1 - 20 of 143" and here I do get previous / next links down to bottom that work. I really need help with this it seem pretty random...

Svemir Brkic (talkcontribs)

I have never encountered an error like that one. Perhaps there are some errors in your logs that may provide a clue?

Mgreis (talkcontribs)

Posting removed - wrong location. I thought the above response was to my question which is actually below. My apologies. I've seen your suggestion there and will respond to it.

Svemir Brkic (talkcontribs)

Those queries look OK to me. Do you get any errors when you run them directly?

Summary by Svemir Brkic

Documentation has been updated not to suggest the confusing way to test things out.

Jake8 (talkcontribs)

Has anyone been able to successfully use this extension with Sphinx version 2.0.4? I receive the following error when "testing out sphinx" (step 4):

 index 'wiki_main': search error: .

The only explanation I can think of is that perhaps the way the config file sets up the index is no longer compatible with the newer version of Sphinx. Has anyone been able to successfully run Sphinx 2.0.4 with their wiki, or should I downgrade my installation to Sphinx 2.0.3? I appreciate any assistance.

Update: The SphinxSearch extension itself appears to be functional even though queries from the command line are not. Feel free to close/delete this support thread.

MWJames (talkcontribs)

Actually we are using 2.0.4 in production with the latests SphinxSearch 0.8+ and we are using the exact same setup as with. (we haven't changed the configuration neither in case of 2.0.3/2.0.4). I'm not sure from where you get the message testing out sphinx, we have never seen this kind of message coming from Sphinx nor SphinxSearch. --MWJames (talk) 00:43, 6 May 2012 (UTC)

Jake8 (talkcontribs)

Oh no, I meant that I received the error in the code block in my original post when following the instructions under the "test out sphinx" step on the SphinxSearch article. The string "testing out sphinx" was never returned from either system.

As I wrote in my update though, SphinxSearch seems to work perfectly on the wiki itself (through the search daemon) even though it's broken from the command line. I have no idea what's causing this, but I guess it must be unique to my system configuration.

Thanks a lot for your help, and for your work on this excellent extension! :)

WhitBlauvelt (talkcontribs)

That's my experience too. The "search" command line function from 2.0.4 (built from source) and 2.0.5 (both built from source and installed from deb) gives "index 'wiki_main': search error: ." if any search terms at all are entered on the command line. However the "searchd" daemon and the MW extension which relies on that work. So the instructions to use "search" to test the installation currently lead to a dead end. Still, "search" is only a test utility, not meant for use once it's in production.