GET FREE VERSION GET THE PRO VERSION

Relevance Score

Learn how plugin search and order product results.

In this article

Relevance Score

All plugin search results order by relevance score. This score is calculated based on where the searched word is placed relative to product content ( title, description, excerpt, ... ).

So, if a searched word is found inside the product title then this product will be placed higher inside search results than the product that has the same word inside its description.  

Relevance of product sources

Relevance of product sources

The plugin also takes into account the number of mentions of each word within the product. More mentions means a higher product in search results.

Products search results sorted by relevance

Products search results sorted by relevance

Also, the search query that fully matches the words inside the product has higher relevance than partial matching.

For example, user search for cap. We have two products inside our WooCommerce store: Cap and Sunglasses with capacity. So the first product title word fully matches with the search query and the second one has only partial match. First product will have a higher relevance score and will be displayed higher inside search results.

Search results for partial and full words match

Search results for partial and full words match

Change relevance scores

The weight of each product field is initially set within the plugin. But it is also possible to change it with some custom code snippets.

Example 1: we want to add more weight to words inside product content and make them more important than words inside product title. This can be done by using aws_relevance_scores filter. Code snippet can looks like this:

add_filter( 'aws_relevance_scores', 'my_aws_relevance_scores' );
function my_aws_relevance_scores( $relevance_array ) {
    $relevance_array['title'] = 100;
    $relevance_array['content'] = 350;
    return $relevance_array;
}

Example 2: we want to add more relevance to the specific product itself. For example, we have a product with ID 123 and we want to always show it at the top of search results.

add_filter( 'aws_search_query_array', 'my_aws_search_query_array' );
function my_aws_search_query_array( $query ) {
    $relevance = '( case when ID = 123 then 800 else 0 end ) + ';
    $query['relevance'] = preg_replace( '/(SUM([sS]*?([sS]*?case[sS]*?end[sS]*?)[sS]*?+/i', '$0' . $relevance, $query['relevance'] );
    return $query;
}

Custom ordering

You can take the sorting of search results completely into your own hands. You can order rules based on different criteria like product date, product stock status, product quantity number, etc.

There are no limits on how you choose to order your search results. All this can be done via custom code snippets. Please read this guide that includes many examples of such ordering functions.