Sorting By Relevance With Drupal Taxonomy
Often it useful to be able to sort content by relevance. For instance, imagine you owned a site that published articles about the city of New York. Imagine this site contained a search page, with a form like this:
These fields hold taxonomy terms. Users can input the terms they want to search for, and the resulting list should be ranked by relevance. That is to say, an article tagged with "new york", "brooklyn", and "nightlife" should appear in the results, but it should rank lower than an article tagged with "new york", "brooklyn", "nightlife", and "community." In short, you want to know which content has been tagged the most with relevant search terms.
This can be done in an extremely performant way, with pure SQL. There is no need to involve a 3rd party search solution, such as Apache Solr. What follows is a set of benchmarks revealing the most performant way to generate this ranked