User:Mattsmith321/Page rank

This is to document the work on better sorting for SphinxSearch results. Current default is to sort by sphinx internal weight, which is calculated based on number of matches within the text, whether they are in the title or in the body, etc. This is how it would be possible to also sort by number of incoming links to the article and article popularity.

Default SearchSphinx results
Here is an example of the default SphinxSearch search results pulled via SphinxQL. Notice that in this wiki many of the pages ended up with the same weight. The examples below show how to improve the ordering of the results.

Basic example - Adding sort parameters
The example below will sort results first by Sphinx weight, but after that by number of links TO that article and by number of article views. Feel free to experiment with the order of these arguments, or to add additional ones.

In sphinx.conf file, make the following changes:

Reindex your wikis and add this to LocalSettings.php after the SphinxSearch.php inclusion:

In LocalSettings.php file, make the following changes after the SphinxSearch.php inclusion:

And finally:
 * Reindex the wiki content
 * Restart the Sphinx search service
 * Restart the Apache service

Verify results
Verify the query results using Extension:SphinxSearch/SphinxQL. Notice that the results have changed slightly and have aligned to the ORDER BY parameters in LocalSettings.php.

Advanced example
The example below shows how to add even more custom columns

Indexing performance
Adding new columns and JOINs will definitely indexing performance and care must be taken to ensure that the new parameters do not have a negative impact. Listed below are the indexing times for a wiki with ~57,000 articles:
 * Default: ~2 minutes
 * Basic example: ~14 minutes
 * Advanced example: TBD