alphagov/rummager — pull request #241 by rboulton (2014-06-11 07:28:32+00:00)
Title: Debug option to explain query ranking

Currently, it's often very hard to say exactly why a document has been returned at a particular position - especially because the indexes on preview and production are often different enough that the rankings are quite different. For example, https://www.gov.uk/search?q=small+business+pension+rules currently returns https://www.gov.uk/foreign-travel-advice/thailand as the top result, and I can't figure out why.

This PR makes use of elasticsearch's "explain" option to return full details of the calculation performed, which should make this much easier. The output takes the form of an extra "_explanation" key in each search result, which is a tree of information reflecting the values calculated throughout the query tree.

The returned information could be displayed in the search result list, but until/unless work is done on frontend to enable that, it will only be accessible via the API (ie, /api/search.json). This is still very helpful.