-
Notifications
You must be signed in to change notification settings - Fork 12
Search Relevance
Relevance sorting is an abstract concept to most people, and it can be difficult for many to understand why one article appears above another in search results. In their mind, article B is clearly more important than article A, so why does article A appear first in the results when they search for something?
If you're looking for a thorough and mathematical explanation, you can read the definitive explanation of Elasticsearch relevance at elastic.co.
Search relevance is fundamentally a combination of three factors:
- How many times the term appears in a page.
- How common or rare the search term is across the entire site.
- The amount of data in the field in which the term appears.
Beyond the basic relevance formula, SearchPress also influences relevance on the field-level. By default, SearchPress tells Elasticsearch that words in the excerpt are twice as important as the main body content, and words in the title are three times as important as the body content. This is very simple to customize.
Relevance can be modified in any number of ways. Some basic ways you might influence relevance are:
- Include more fields in the search
- Change the relative importance of fields
Customization doesn't stop there. Some advanced examples of influencing relevance include:
- Boosting the top articles on the site as reported by site analytics
- Using a decay algorithm, so newer articles are inherently considered more important than older ones
- Boosting specific content types over others, or posts in one category versus another
You can find code samples on Customizing Relevance.