alphagov/rummager — pull request #233 by rboulton (2014-05-22 15:20:40+00:00)
Title: Use best bets

This causes rummager to actually use best bets when searching.

Best bets are sent over HTTP from the search-admin application to the best_bets table. This PR provides a schema for the best bets. At search time, the best bets table is queried to see if any best bets should be applied, based on the user's query. If best bets are found, they are combined to produce a suggested list of positions for each "forced" result position. There is also a concept of "worst bets", which are documents which are actively removed from the search results list. This will be used sparingly! (There is currently no option to "downweight" a document).

There are two types of best bets. An exact-match best bet is simple to implement, and is used only if the user's query is an exact match (other than case and whitespace) for the best bet. It has priority over the other type of best bet, which is a "stemmed phrase" match. This is more complex to implement, and I suggest reading the commit message for https://github.com/alphagov/rummager/commit/2b2b979353a5dce0ea1a87743eba8a1007e80011 for more insight on why I've implemented it as I have.