Development

5 min read

Fine-Tuning Search Results with Broadleaf's Relevancy Rules

Skye Pekerti

Written by Skye Pekerti

Published on Aug 26, 2025

Relevancy Rules

Nobody likes a search that returns 10,000 results for "blue shirt." Your customers want the blue shirt, the one that fits their style, budget, and needs. That's where search relevancy becomes critical for eCommerce success.

Broadleaf's search functionality has been set up to work well out of the box, but sometimes you need more control over the search results. You may want to push discounted items higher up during Black Friday, or boost products with better ratings. Relevancy Rules give you that control without touching code.

How Broadleaf Search Works

Behind the scenes, Broadleaf uses Apache Solr to manage search functionality. However,  you don't need to be a Solr expert in order to tailor search results to your needs. Our Search Services create a clean API layer that handles the bulk of search complexity for you.

The two most important key concepts are the FieldDefinition and FieldVariant.

  • A FieldDefinition is the main component used in a search. Each FieldDefinition tells the system what data should be indexed. Think of it as defining a searchable attribute like a product’s "name", "brand", or even a list of “keywords”.
  • A FieldVariant can be thought of as a branch off of a FieldDefinition because it allows you to index the same data multiple ways for different search behaviors. For example, a product name might have a string-based variant, which is only indexed for exact matches, and a text-based variant for fuzzy-text that handles typos and partial matches. In Solr, these would be indexed as two completely separate entries, one for name_s and another for name_t.

Once a user searches for an item, Broadleaf runs multiple query types simultaneously: word matches, phrase matches, and exact matches. Most of the time, this gives you solid results without any tweaking.

But what if you want more control over the ordering of results? That's where Relevancy Rules enable boosting of searches to show preferred items. 

The Four Rule Types

Relevancy Rules work by boosting results which match a defined set of criteria. If matched, the items will show up before similar results that do not match the rules. There are four different approaches in that Relevancy Rules can be utilized:

  • Matching Query Rules: These rules boost items when a specified search field contains the search term. If someone searches for "laptop," you might want matches with “laptop” in the product name to show up before matches buried in product descriptions. 
  • Matching Value Rules: These rules are more targeted and boost items when a field contains an exact value you specify. Running a "Summer Sale" promotion? Set up a rule that boosts any product tagged with "Summer Sale" when someone searches for "summer."
    • You can also enable frequency boosting for these rules, allowing further boosting of results if the value is mentioned multiple times in a field. As an example, if a product mentions "summer" five times versus once, the frequent mentions get a bigger boost.
  • Relative Rules: These rules are perfect for numeric fields like ratings or prices. They boost higher-rated products to the top, or push lower-priced items up for budget-conscious searches.
  • Ordinal Rules: These handle alphabetical sorting for text fields. Useful when you want products starting with "A" to appear before "Z." This is a niche use, but it's valuable for general browsing pages or when maintaining consistent ordering within result groups.
    • Out of the box, we do not show Original Rules as an option due to the small use case.

To make sure that results don’t get over-skewed, such as the case of Relative Rules, a minimum score is applied to ensure there is a minimum limit.

Setting Up Rules (No Code Required)

The Broadleaf Admin console will allow you to handle rule creation without requiring a change to any code. Under Search settings in the navigation panel, you'll be able to configure and create Relevancy Rules.

  1. Name your rule; be sure that the name is descriptive for your team. 
  2. Set a start and end date range for when it's active (useful for seasonal promotions). By default, the start date will be generated on the day you create the rule, and an end date is optional.
  3. Select which FieldDefinition and FieldVariant the rule affects
  4. Choose your rule type from the four options, being sure it fits your needs as described by their use cases above.
  5. Set the boost value to determine the influence of the rule. 
  6. Optionally limit rules to specific search terms based on an extra set of rules or matching..

You can also group rules together and assign different groups to different parts of your site. For example, your admin search needs might use different relevancy logic than your customer-facing storefront.

Note that these tools aren’t just for developers. Marketing teams can create a rule to promote specific brands during campaigns, and Product managers can boost items with better margins during slow periods. No code deployments needed.

Real-World Impact

Search relevancy works best when customers don't notice it. They find what they want quickly and move on. When it's broken, the frustration is obvious. Customers bounce after digging through pages of irrelevant results.

Relevancy Rules help align search results with business goals. You can promote seasonal items, highlight profitable products, or showcase highly-rated merchandise without complex development work.

The beauty is in the flexibility. You can start simple with a few basic rules, then add sophistication as you learn what works for your catalog and customers.

Bottom Line

Broadleaf's search foundation is solid, but Relevancy Rules give you the fine-tuning control that separates good eCommerce search from great search. Whether you're optimizing for conversions, customer satisfaction, or business priorities, having this level of control over search results is invaluable.

The best part? Your business users can manage most of this themselves, freeing up development time for other priorities.

Related Resources