Extension:SphinxSearch/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.

In sphinx.conf file, source src_wiki_main section, after this line:

sql_query_pre = SET NAMES utf8

ADD another query that creates a temporary table with incoming link counts:

CHANGE sql_query attribute to pick this data up, and also to get page_counter field which stores numbers of article hits:

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:

This 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.