Boosting Query in Elasticsearch
📖 Scenario: You are building a search feature for an online bookstore. You want to show books that match the user's search term but also want to reduce the rank of books that contain certain negative keywords.
🎯 Goal: Create an Elasticsearch boosting query that increases the score of documents matching a positive term and decreases the score of documents matching a negative term.
📋 What You'll Learn
Create an initial query with a positive match on the field
title for the word "adventure".Add a negative match on the field
description for the word "boring".Set the
negative_boost value to 0.2 to reduce the score of negative matches.Print the final JSON query.
💡 Why This Matters
🌍 Real World
Boosting queries help improve search results by promoting relevant documents and demoting less relevant ones, making search more useful for users.
💼 Career
Understanding boosting queries is important for roles involving search engine optimization, data engineering, and backend development with Elasticsearch.
Progress0 / 4 steps