Stopwords

Table of Contents

What are stopwords?

Stopwords are “(…) a set of commonly used words in a language. Examples of stop words in English are “a”, “the”, “is”, “are” and etc. Stop words are commonly used in (…) Natural Language Processing (NLP) to eliminate words that are so commonly used that they carry very little useful information.”1

In e-commerce, stopwords will be any set of words that are so ubiquitous around a particular store that searching the store will become next to impossible. We decided to divide stopwords into two separate categories for FiboSearch to perform even more efficiently.

Stopwords while searching

This will come in handy when you, as the owner, want to cut any set of words from customer queries to help refine the query.

Let’s imagine that you run an electronic store and want to sell the latest iPhone cases. The product name is “iPhone case”, but many users will try to find a “case for an iPhone” or “an iPhone case”. Unfortunately, this will return a no-results page, as the queries don’t match the names: the words “an” and “for” are not present in the product name.

When you add those words (“an” and “for”) to your stopwords list, those words will be cut out from the query. Consequently, the search engine will be fed the phrase “case iPhone” – and present a list of matching products for your customers.

Stopwords while indexing

This will be a good fit when some phrases used globally in your store also match some specific product names or descriptions.

A good example is when you allow customers to search in the descriptions and every item has the phrase “Installment payment” applied. However, you also have some products like “electrical installation accessory” and others which contain the word “install****” in it. When customers try to find those products, they will be presented with a list of every possible product in your store, because the phrase “installment payment” shares the same root and the engine will see it as a direct match.

To help your customers (and your conversions!) and help them find the right products, you can add words “installment” and “payment” to your stopwords set, the results page will present only products matching the phrase “electrical installation accessory”.

Managing stop words using FiboSearch

As of now, stopwords cannot be defined from the plugin’s settings and you have to use code snippets. As mentioned before, with FiboSearch stopwords are divided into two separate categories. 

Stopwords while indexing

A set ignored while indexing the products – when you add new products which include words from the set, they will be ignored altogether and not indexed. Any word that is added to the stopwords list will be non-searchable.

To add the code, you can either:

  1. Open the functions.php file in your child theme and add the code at the end
  2. Or install the Code Snippets plugin and apply this code as a snippet.
add_filter( 'dgwt/wcas/indexer/searchable/stopwords', function ( $stopwords, $type, $object_id, $lang ) {
   return [ 'and', 'the' ];
}, 10, 4 );

Stopwords while searching

A set ignored while searching – words from the set are ignored while customers type their query into the search bar.

For example, when customers search for a “dress with stripes pattern”, the size from the query will be omitted and the phrase “dress with stripes” will enter the engine

To add stopwords for your shop, you have to add the code to the fibosearch.php file.

First, create a new empty fibosearch.php file in the root directory of your child-theme. For more information on child themes, please refer to this tutorial.

add_filter( 'dgwt/wcas/search/stopwords', function ( $stopwords, $lang ) {
   return [ 'and', 'the' ];
}, 10, 2 );

1 https://www.opinosis-analytics.com/knowledge-base/stop-words-explained/