Search Weights

You are here:

Weights improve the relevance in product search results, based on search keyword matches in product titles, excerpts (product short descriptions), contents, tags, categories, product attributes and their SKU.

Weights can also be set for specific products and product categories, to fine-tune the order in which products appear in product search results.

The use of Search Weights can have a significant impact on the relevance of product search results. You must enable the option to use weights before they are taken into account and the additional settings for search weights are displayed when products and product categories are edited.

Use weights

To enable the use of weights, go to WooCommerce > Settings > Search, check the option Use weights and save the changes.blank

Note that when we refer to weights within the context of this extension, we refer to search weights only and never to the actual physical weight of a product.

Relevance

The weight settings determine the relevance of matches in the product title, short description (excerpt), its content and its related tags.

Weights can be set for the following product elements:

  • Title – this affects the relevance of a product when its title matches one or more search keywords
  • Excerpt – for matching keywords in the product’s short description
  • Content – when matching search keywords are found in the product’s content
  • Tags – where search keywords match tags that are related to a product
  • Categories – where search keywords match categories that are related to a product
  • Attributes – when there is a matching attribute term related to a product
  • SKU – when the SKU matches the search

By default, a set of weights is provided which assign a higher relevance to products with matches in the title, short description or related tags, while leaving matches in the product content at their default.

blank

The relatively high title weight used by default, will promote search results that have matches in the title substantially, compared to matches in other aspects of the product.

Note that the search weight of products and product categories can be modified individually, the computed sum of weights determines the relevance of a product in search results.

Setting the Search Weight of specific Products

If search weights are enabled, their value can be adjusted individually for each product. Positive values will promote the relevance of a product when it appears in product search results, while negative values will demote it. If a product’s search weight is set to 0 or is not specified, its relevance is determined by the general values for matching keywords only.blank

The Search Weight setting in the Search section under Product Data, when editing a product.

To set the search weight of a specific product, go to Products and edit the desired product. Under Product Data > Search, adjust the Search Weight. The value will be added to the product’s sum of weights when it appears in product search results and will adjust its position with respect to the search weights of other products that also appear as results.

Setting the Search Weight of specific Product Categories

If enabled, search weights can be set for product categories. These are used to adjust the relevance of all products that belong to a category.

blank
The Search Weight setting when editing a product category

To set the search weight of a category, go to Products > Categories and edit the desired category. Set a positive value to promote all products in the category or a negative value to demote them. The value is added to the product’s sum of weights similar to how a product’s individual search weight impacts its overall relevance. If a product belongs to several categories for which weights have been set, the maximum value is taken into account. For example, if a product belongs to Category A with a search weight set to 100 and Category B’s search weight 200, the product’s category search weight will be 200.

As of version 3, the weights are accumulative through the hierarchy of categories. This means that any child category’s weight will be the sum of its ancestors’ weights and its own assigned weight. As you may use both positive and negative weights, this allows you to fine-tune specific sub-categories as needed. For example, you could promote a specific sub-category for seasonal demand by adding a positive weight to it, while demoting others assigning a negative weight.

As an example, assume you have a root category Clothing and two sub-categories Shirts and Pants. If we assign a weight of 100 to the Clothing category and do not assign any particular weight to either the Shirts or Pants sub-categories, both will inherit the weight of 100. But if we assign 25 to Shirts and -10 to Pants, the resulting effective weight will be 125 for Shirts and 90 for Pants.

How Search Weights Work

Search Weights are calculated by summing weights based on matches in the product title, description, content and other factors as described above, plus category weights and individual product weights if they are set for products that are included in search results. To better help you understand how this works, we provide the following examples.

To make things easier to understand, we have simplified the examples and include only the title, excerpt, content and tags in our considerations.

Assuming the default settings under WooCommerce > Search > Weights > Relevance

Title 50
Excerpt 20
Content 0
Tags 10
  • Any matching search keyword will sum 50 when it occurs in the title. One matching keyword will sum 50 to the product’s relevance, two matching keywords in the title will sum 100 etc.
  • Matching keywords in the excerpt sum 20 each.
  • As the weight for content is set at 0, matches in the product’s content will not increase or decrease the relevance in search results.
  • Tags are set to sum 10 per match, for example, three matching keywords in a product’s related tags will sum 30 to its relevance.

If a product or a product category defines a specific weight, it is added to the weights obtained based on these settings.

Let’s assume these three products :

  • Product ID : 1
  • Title: Yellow Banana
  • Excerpt: A fruity experience full of joy
  • Content: The Yellow Banana is a tasteful experience for the connoisseur.
  • Tags: fruit, yellow, banana, sweet
  • Product ID : 2
  • Title: Green Apple
  • Excerpt: It’s pretty sour!
  • Content: An apple a day keeps the doctor away. This is a green apple, other varieties such as red or yellow apples are also available.
  • Tags: fruit, green, apple, sour
  • Product ID : 3
  • Title: Red Orange
  • Excerpt: Great for juice and cakes!
  • Content: The Red Orange is the prettier variety of the ordinary Orange, with a deep red color and intense flavor.
  • Tags: red, orange, juice, fruit
  • Search Weight: 11 – Note that this product has a specific search weight defined.

Here are some example searches and computed weights. Only the computed weights of products that are included in search results are shown.

  • Search #1 : fruit

W(1) = 20 + 10 = 30
W(2) = 10
W(3) = 10 + 11 = 21

Results in order of relevance: 1, 3, 2

  • Search #2 : red fruit

W(1) = 20 + 10 = 30
W(2) = 10
W(3) = 10 + 10 + 11 = 31

Results in order of relevance: 3, 2

  • Search #3 : green orange

W(2) = 50
W(3) = 50 + 11 = 61

Results in order of relevance : –

  • Search #4 : red orange

W(2) = 0
W(3) = 50 + 50 + 11 = 111

Results in order of relevance : 3

Was this article helpful?
Dislike 0
Views: 15