Skip to main content

Posts

Showing posts from 2025

Enrich Search Results with Personalized Sorting in Elasticsearch

Greetings! Personalization is a key e-commerce feature for enhancing user experience and driving sales. One aspect of this is improving search results through recommendations, helping to surface more buyable products for the customer. Business opportunities Boost sales by sorting search results based on customer recommendations. Technical opportunity A business opportunity often comes with fascinating technical challenges. While Elasticsearch makes sorting easier, this doesn’t seem like something we can achieve with standard sorting alone (but we can). Sort by script Elasticsearch offers multiple search options, including custom scripts that allow us to define our own sorting logic. "sort": { "_script": { "type": "number", "script": { "lang": "painless", "inline": "doc[ 'field_name' ].value * params.factor", "params": { "f...

Implementing Faceted Search and Dynamic Filtering in Elasticsearch

Greetings! Faceting is a widely used concept in search and data filtering across various technologies and domains. It is commonly applied in e-commerce, healthcare, travel, and many other fields to enhance user experience. Most databases support faceting (filtering) for this purpose. In this article, I will focus on developing a facet search using Elasticsearch with movie data. Elasticsearch Aggregation Elasticsearch offers a powerful aggregation feature that enables querying and analyzing data efficiently. With a single query, you can retrieve both filters and search results, allowing for complex analyses and meaningful insights. Terms Aggregation This is used to group documents based on unique values of a specified field. { "aggs": { "genres": { "terms": { "field": "genre", "size": 100 } } } } Range Aggregation This groups documents into predefined numerical or date ranges. It is usefu...