Search API Numeric Boost
Ever have a need to increase or decrease a product, blog post or other entity in the your search results? Here’s one way to accomplish this by adding a number field to your content type and some Search API configuration. The Search Boost here means increasing or decreasing a item in the search results. I’m doing this in Drupal 10.3.
Using a product content type as an example.
Add a number field
Add a Number (integer) field type
Set an appropriate field title such as “Search Boost” or “Numeric Search Boost”
We’ll want a range of negative to positive numbers, say -10 to 10
Minimum: -10
Maximum: 10
Optional: Set the default value to 0
With 0 the boost factor should not have an effect
Configure Search API
Make sure the Search API modules are installed (enabled)
Note: Assuming you already have a search server and index already created and working
Go to the Search API in the admin
/admin/config/search/search-api
Edit the search index
Under the Fields tab add your new search boost field as an Integer Type
Under the Processors tab enable “Number field-based boosting”
Scroll down to the Number field-based boosting tab
For your new field set the Boost factor
I used 2.0 which has done a good job with the -10 to 10 range we set above, but test out different values and the effects
Save
Change Boost Value And Re-index Search
Change the value of your new field to a negative number to lower the search boost and push the item (product) lower in the search results, last page of results, or a positive number to increase the product in the search result, first page of results.
Re-index the search index
Hope this helps 🚀