Search by Algolia
What is a B2B marketplace?
e-commerce

What is a B2B marketplace?

It’s no secret that B2B (business-to-business) transactions have largely migrated online. According to Gartner, by 2025, 80 ...

Vincent Caruana

Sr. SEO Web Digital Marketing Manager

3 strategies for B2B ecommerce growth: key takeaways from B2B Online - Chicago
e-commerce

3 strategies for B2B ecommerce growth: key takeaways from B2B Online - Chicago

Twice a year, B2B Online brings together industry leaders to discuss the trends affecting the B2B ecommerce industry. At the ...

Elena Moravec

Director of Product Marketing & Strategy

Deconstructing smart digital merchandising
e-commerce

Deconstructing smart digital merchandising

This is Part 2 of a series that dives into the transformational journey made by digital merchandising to drive positive ...

Benoit Reulier
Reshma Iyer

Benoit Reulier &

Reshma Iyer

The death of traditional shopping: How AI-powered conversational commerce changes everything
ai

The death of traditional shopping: How AI-powered conversational commerce changes everything

Get ready for the ride: online shopping is about to be completely upended by AI. Over the past few years ...

Aayush Iyer

Director, User Experience & UI Platform

What is B2C ecommerce? Models, examples, and definitions
e-commerce

What is B2C ecommerce? Models, examples, and definitions

Remember life before online shopping? When you had to actually leave the house for a brick-and-mortar store to ...

Catherine Dee

Search and Discovery writer

What are marketplace platforms and software? Why are they important?
e-commerce

What are marketplace platforms and software? Why are they important?

If you imagine pushing a virtual shopping cart down the aisles of an online store, or browsing items in an ...

Vincent Caruana

Sr. SEO Web Digital Marketing Manager

What is an online marketplace?
e-commerce

What is an online marketplace?

Remember the world before the convenience of online commerce? Before the pandemic, before the proliferation of ecommerce sites, when the ...

Catherine Dee

Search and Discovery writer

10 ways AI is transforming ecommerce
e-commerce

10 ways AI is transforming ecommerce

Artificial intelligence (AI) is no longer just the stuff of scary futuristic movies; it’s recently burst into the headlines ...

Catherine Dee

Search and Discovery writer

AI as a Service (AIaaS) in the era of "buy not build"
ai

AI as a Service (AIaaS) in the era of "buy not build"

Imagine you are the CTO of a company that has just undergone a massive decade long digital transformation. You’ve ...

Sean Mullaney

CTO @Algolia

By the numbers: the ROI of keyword and AI site search for digital commerce
product

By the numbers: the ROI of keyword and AI site search for digital commerce

Did you know that the tiny search bar at the top of many ecommerce sites can offer an outsized return ...

Jon Silvers

Director, Digital Marketing

Using pre-trained AI algorithms to solve the cold start problem
ai

Using pre-trained AI algorithms to solve the cold start problem

Artificial intelligence (AI) has quickly moved from hot topic to everyday life. Now, ecommerce businesses are beginning to clearly see ...

Etienne Martin

VP of Product

Introducing Algolia NeuralSearch
product

Introducing Algolia NeuralSearch

We couldn’t be more excited to announce the availability of our breakthrough product, Algolia NeuralSearch. The world has stepped ...

Bernadette Nixon

Chief Executive Officer and Board Member at Algolia

AI is eating ecommerce
ai

AI is eating ecommerce

The ecommerce industry has experienced steady and reliable growth over the last 20 years (albeit interrupted briefly by a global ...

Sean Mullaney

CTO @Algolia

Semantic textual similarity: a game changer for search results and recommendations
product

Semantic textual similarity: a game changer for search results and recommendations

As an ecommerce professional, you know the importance of providing a five-star search experience on your site or in ...

Vincent Caruana

Sr. SEO Web Digital Marketing Manager

What is hashing and how does it improve website and app search?
ai

What is hashing and how does it improve website and app search?

Hashing.   Yep, you read that right.   Not hashtags. Not golden, crisp-on-the-outside, melty-on-the-inside hash browns ...

Catherine Dee

Search and Discovery writer

Conference Recap: ECIR23 Take-aways
engineering

Conference Recap: ECIR23 Take-aways

We’re just back from ECIR23, the leading European conference around Information Retrieval systems, which ran its 45th edition in ...

Paul-Louis Nech

Senior ML Engineer

What is a neural network and how many types are there?
ai

What is a neural network and how many types are there?

Your grandfather wears those comfy slipper-y shoes all day, every day, and they’re starting to get holes in ...

Vincent Caruana

Sr. SEO Web Digital Marketing Manager

10 reasons AI search is the next big thing
ai

10 reasons AI search is the next big thing

Every time I look at the news, there is another article about the race to build new search and discovery ...

Michelle Adams

Chief Revenue Officer at Algolia

Looking for something?

facebookfacebooklinkedinlinkedintwittertwittermailmail

Today, we are releasing Query Rules, a new feature which enables you to modify, override, & enhance the behavior of the engine’s configured ranking for a subset of the queries. We wanted to share with you how we approached this key addition to our API, why we decided to build it, and explain the design steps leading to the release today.

Before we dive in, let’s look at a few examples of what you can do with Query Rules:

  • Transform descriptive text into a filter: for example, by automatically transforming a query word into its equivalent filter (“cheap” would become a filter price< 400; “red” a filter on the color…)
  • Merchandising: manually select a result for a specific query (e.g., decide that the latest iPhone 8 should be in the first position for the query iPhone)
  • Entities detection: detect entities (colors, brands…) in the queries and transform them into filters or boosts

Building upon our ranking formula

With Algolia, the same relevance algorithm is applied across the entire index. We expose features like Custom Ranking so that customers can customize the ranking strategy for their needs, and achieve a great relevance for the vast majority of queries. However, in the past few years, our customers started to bring to us examples of outlier queries.

We began compiling a list of these outlier situations. Here are a few examples:

  • When Apple releases a new iPhone, it should be in the first position of the list for the query “iPhone” (even though at this stage it has no views, no sales… no “logical” reason to be ranked high)
  • You need to get rid of a big stock of a specific model of a vacuum cleaner, so you’d like it to be promoted in the results (at least until enough units are sold)
  • The query “phone” naturally (according to the configured ranking strategy) retrieves feature phones instead of smartphones, but you’d like to highlight smartphones first
  • The query “red dress” matches with non-red results because the name of the brand begins by “red”
  • The query “cheap phone” doesn’t return any results (the records don’t contain the word cheap), and would behave better if “cheap” was transformed into a numeric filter on the price
  • Queries originating from users on mobile devices should highlight results that are mobile-friendly

There are hundreds of examples like this where having an exception to the general rule would make sense, either to improve the relevance, or to override the ranking for business reasons.

Thinking about our options

There are two main ways to address the types of exceptions we were seeing. The natural way to handle this would be to analyze the use cases one by one and add a configuration to the engine to handle each of them individually. We could, for example, develop a form of synonyms that would transform a word into a filter. Eventually, these settings would form a merchandising tool, allowing users to tweak and override the ranking logic.

We certainly had the experience on the team to execute on this approach. Several team members, including our founders, have used, or even built merchandising platforms prior to founding/working for Algolia. However, it is exactly because of this experience that we had doubts that this was the right approach:

  • Creating a new setting inside the engine for each exception quickly leads to a bloated solution: there are just too many varieties of merchandising strategies
  • Building a quality merchandising tool that would work for all of our users – each of whom have specific needs & exceptions – is virtually impossible
  • Multiplying the exceptions inevitably affects performance

More importantly, we wanted to do more than merchandising and address the needs of other industries. Media sites don’t use merchandising, but they still want to promote, for example, partner content. SaaS systems may want to improve the ranking by adding rules automatically based on the output of a machine learning tool.

To do this, we would need to be able to impact search results on a subset of queries in two distinct places:

  • Before the search query is processed, in order to override the query parameters
  • After the results are found, in order to modify the results list

The solution

What we came up with is a rules system for queries — or Query Rules — that sits inside the engine via two modules:

  • A query preprocessing module that will modify the search parameters before the search is processed by the engine
  • A results postprocessing module that will modify the results before they are sent back to our users

Each rule has the following pattern: IF the query contains X, THEN modify Y. A condition and a consequence:

  • If the query contains “iPhone”, add this result in the first position
  • If the query is “cheap phone”, replace the word “cheap” by a numeric filter price<200
  • If the query contains a color, filter by that color

This approach makes it simple to modify the behavior of a subset of the queries, without impacting the rest of the queries. We created two types of conditions, and seven types of consequences, which together allow us to handle a variety of exceptions, including:

  • Promote the latest iPhone on the query “iphone”
  • Filter on color white for the query “white dress”
  • Filter on price<400 for the query “cheap phone”
  • Display a promotional banner for the query Samsung
  • Remove the word “hotel” in a hotels search

Conclusion

With Query Rules, we’re bringing to Algolia the ability to handle queries on an individual basis by making exceptions on the regular ranking strategy.

We think the approach we took has a few interesting benefits:

  • It is low-level and flexible enough to adapt to a large variety of use-cases without requiring a lot of settings and configuration
  • It is exposed via an API, allowing both our customers and potential partners specialized on merchandising to build upon it
  • It doesn’t compromise performance for the sake of feature sets: you can add up to a million rules to an index, with little to no impact on search performance

In fact, we like to think of Query Rules as more than a feature: we like to think of it as an extension of our engine. We have designed it to be open-ended enough to allow our users to solve their own unique problems and push the boundaries of what is possible with search.

It’s been exciting to start sharing the feature with a few beta testers — we’ve been amazed at how easily they grasped its potential, and the combinations it allows.

The two conditions and seven consequences we are initially releasing are only the beginning — we look forward to getting your feedback and learning which ones you’d like us to add next!


Meanwhile, we put together an online workshop, where two of our team members will show you in practice how to create smarter search with Query Rules.
=> You can register here.

About the author
Nicolas Baissas

Smarter search strategies to engage your users

How to apply business logic for more relevant search results.

Image of Jason HarrisImage of Olivier Lance
Jason Harris - Developer AdvocateOlivier Lance - Solutions Engineer
Image of Jason Harris
Jason HarrisDeveloper Advocate
Image of Olivier Lance
Olivier LanceSolutions Engineer
Smarter search strategies to engage your users Watch the webinar

Recommended Articles

Powered byAlgolia Algolia Recommend

Algolia's top 10 tips to achieve highly relevant search results
product

Julien Lemoine

Co-founder & former CTO at Algolia

What is a search query and how is it processed by a search engine?
product

Catherine Dee

Search and Discovery writer

How Algolia uses AI to deliver smarter search
ai

Julien Lemoine

Co-founder & former CTO at Algolia