Table of contents :

Managing Multilingual WooCommerce Stores with Elasticsearch

WordPress search plugin with Elasticsearch

Table of contents :


Managing multilingual WooCommerce stores can be a complex task, especially when it comes to implementing efficient search functionality. One powerful tool that can greatly enhance search capabilities in such scenarios is Elasticsearch. Elasticsearch is an open-source, highly scalable search and analytics engine built on top of Apache Lucene. With its powerful indexing and querying capabilities, it is an excellent choice for managing multilingual WooCommerce stores. In this post, we will explore how Elasticsearch can be used to effectively manage multilingual WooCommerce stores and provide seamless search experiences across different languages.


Using the PHP Client for Elasticsearch

To interact with Elasticsearch using PHP, we can utilize the official Elasticsearch PHP client library. This library provides a convenient and efficient way to communicate with the Elasticsearch cluster. Let’s dive into some code examples to illustrate how we can use the PHP client for managing multilingual WooCommerce stores.

First, we need to install the Elasticsearch PHP client library using Composer. Open your terminal and navigate to your project directory. Then, run the following command:

composer require elasticsearch/elasticsearch

Once the library is installed, we can create an instance of the Elasticsearch client and start performing various operations. Here’s an example of connecting to an Elasticsearch cluster:

require 'vendor/autoload.php';

$client = Elasticsearch\ClientBuilder::create()->build();

Indexing Multilingual Data:
To manage multilingual data in Elasticsearch, we can leverage its support for language analyzers. Language analyzers help in tokenizing and normalizing text based on the language-specific rules. When indexing multilingual data, it’s important to specify the appropriate language analyzer for each field. Here’s an example of indexing a product with a multilingual name:

$params = [
 'index' => 'products',
 'id' => '1',
 'body' => [
  'name' => [
   'en' => 'Black T-Shirt',
   'es' => 'Camiseta Negra',
   'fr' => 'T-shirt Noir'
  'description' => [
   'en' => 'A stylish black t-shirt for men.',
   'es' => 'Una elegante camiseta negra para hombres.',
   'fr' => 'Un t-shirt noir élégant pour hommes.'
  // Other product fields...

$response = $client->index($params);

Searching Multilingual Data

When performing searches in a multilingual WooCommerce store, it’s crucial to consider the user’s language preference. Elasticsearch provides powerful querying capabilities, including support for multi-match queries that can search across multiple fields simultaneously. Here’s an example of performing a multilingual search for products:

$params = [
 'index' => 'products',
 'body' => [
  'query' => [
   'multi_match' => [
    'query' => 'black t-shirt',
    'fields' => ['name.*', 'description.*']

$response = $client->search($params);

Multilingual Analyzers

When working with multilingual WooCommerce stores, it’s essential to consider the nuances of different languages during indexing and searching. Elasticsearch offers multilingual analyzers that help handle language-specific tokenization, stemming, and normalization. These analyzers play a crucial role in accurately indexing and retrieving multilingual data. Let’s explore some key concepts related to multilingual analyzers in Elasticsearch.

1. Language Analyzers:
Elasticsearch provides a range of language-specific analyzers that cater to different languages. These analyzers are designed to handle specific linguistic characteristics, such as word tokenization, stemming, and stop-word removal. Language analyzers ensure that text in different languages is processed appropriately during indexing and searching, improving the relevance and accuracy of search results.

2. Stemming:
Stemming is the process of reducing words to their base or root form. For example, in English, stemming converts “running” and “runner” to their base form “run.” This process allows for more comprehensive search results by matching different variations of a word. Elasticsearch includes language-specific stemmers that can be applied during analysis.

3. Stop-Words:
Stop-words are common words that typically do not carry much meaning and are often ignored during search operations. Examples of stop-words include “the,” “is,” “and,” etc. Elasticsearch provides language-specific stop-word lists that can be utilized to improve search efficiency and relevance.

4. Normalization:
Normalization ensures that different forms of characters are treated equally during search operations. For instance, in some languages, there may be accented characters or different letter cases that need to be normalized for proper indexing and searching. Elasticsearch offers language-specific normalizers that handle such cases.

By utilizing the appropriate language analyzers, stemmers, stop-word lists, and normalizers, you can ensure that your multilingual WooCommerce store is accurately indexed and efficiently searchable across different languages.


WPSOLR for Multilingual WooCommerce Stores

When managing multilingual WooCommerce stores, integrating a powerful search solution becomes paramount. WPSOLR is a WordPress plugin that can greatly enhance search capabilities, including multilingual support. By leveraging WPSOLR in combination with popular multilingual plugins like WPML and Polylang, you can achieve a seamless multilingual search experience. Let’s delve into the key features and benefits of WPSOLR for managing multilingual WooCommerce stores.

1. Integration with Multilingual Plugins:
WPSOLR seamlessly integrates with multilingual plugins such as WPML and Polylang, ensuring that your search functionality works flawlessly across different languages. It understands the multilingual structure of your site and indexes content accordingly, allowing users to search and retrieve results in their preferred language.

2. Indexing Multilingual Content:
WPSOLR indexes content from multiple languages and creates language-specific indexes, enabling efficient search operations. It leverages the language settings from the multilingual plugins to ensure that each language’s content is indexed correctly and can be searched independently.

3. Language Switching:
WPSOLR provides language-specific search filters, allowing users to search within a specific language. It seamlessly integrates with language switchers provided by multilingual plugins, enabling users to switch languages and get search results relevant to their language preference.

4. Relevance and Ranking:
WPSOLR offers powerful ranking algorithms and relevance tuning options. It takes into account language-specific nuances, such as stemming and word weightings, to ensure accurate and relevant search results. You can fine-tune the ranking parameters to prioritize certain languages or specific content for better search experiences.

5. Faceted Search and Filters:
WPSOLR supports faceted search, which allows users to refine their search results by applying filters based on different attributes like category, price range, or language. This feature enhances

the user experience by enabling precise filtering in a multilingual context.

By integrating WPSOLR with multilingual plugins like WPML and Polylang, you can effectively manage multilingual WooCommerce stores and provide an enhanced search experience tailored to each language.

Managing multilingual WooCommerce stores requires addressing language-specific challenges in search functionality. By utilizing multilingual analyzers provided by Elasticsearch, you can handle language nuances effectively. Additionally, integrating WPSOLR with multilingual plugins like WPML and Polylang can greatly enhance the search capabilities of your WooCommerce store, offering language-specific indexing, language switching, relevance tuning, and faceted search. With these powerful tools at your disposal, you can create a seamless and efficient multilingual search experience for your WooCommerce customers.



Managing multilingual WooCommerce stores requires effective search functionality to provide a seamless experience for users across different languages. Elasticsearch, with its powerful indexing and querying capabilities, is an excellent choice for achieving this goal. By utilizing the Elasticsearch PHP client library, we can easily interact with Elasticsearch and implement multilingual search functionality in our WooCommerce stores. With the examples provided in this post, you should now have a good starting point to leverage Elasticsearch in managing multilingual WooCommerce stores effectively.

Related posts ... not powered by WPSOLR 😊

How AI search is transforming healthcare

Introduction Artificial intelligence (AI) search is quickly transforming the healthcare industry by providing healthcare professionals with tools to improve patient outcomes, diagnosis, and treatment. AI