How weights work
Each query in a federated multi-search request can include afederationOptions object with a weight property. The weight is a floating-point number that multiplies the ranking rules relevancy score of results from that query:
- The default weight is
1.0 - A weight higher than
1.0promotes results from that query - A weight lower than
1.0demotes results from that query - A weight of
0.0effectively excludes results from that query
Boost results from a specific index
Suppose you have a CRM application with three indexes:profiles, chats, and tickets. When searching for a person’s contact information, results from the profiles index are most likely to contain what you need. You can boost those results by giving the profiles query a higher weight.
profiles query has a weight of 1.2, while the other queries use the default weight of 1.0. This means matching profiles will rank higher in the merged result list.
The response returns all results in a single list, with profile matches promoted toward the top:
_federation object showing which index and query position it came from.
Practical example: products over blog posts
For an ecommerce site with both aproducts index and a blog_posts index, you likely want product listings to appear before blog content when users search:
1.5 on products and 0.8 on blog posts, product results will consistently appear higher in the merged list unless a blog post has a significantly better relevancy match.
Tips for choosing weights
- Start with small adjustments (for example,
1.2for promoted indexes and0.8for demoted ones) and test with real queries - Use larger differences (for example,
2.0vs0.5) when you need a strong preference for one content type - Remember that weights multiply the relevancy score, so a highly relevant result from a low-weight index can still outrank a weakly relevant result from a high-weight index
Next steps
Federated search
Learn how to perform a basic federated search
Build a unified search bar
Combine federated search with a frontend UI