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, source src_wiki_main section:

ADD two new attributes to the list below the query:

sql_attr_uint  = page_counter sql_attr_uint  = pl_count

CHANGE sql_query in source src_wiki_incremental section to match the main query (your query page_touched... part may vary, and note that we are moving rev_id=page_latest and old_id=rev_text_id from WHERE to INNER JOINs)

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

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

Indexing performance
Indexing performance for wiki with ~57,000 articles:
 * Default: ~2 minutes
 * Basic example: Started at 1:13pm
 * Advanced example: TODO