0
0
Elasticsearchquery~3 mins

Why Relevance score (_score) in Elasticsearch? - Purpose & Use Cases

Choose your learning style9 modes available
The Big Idea

What if your search could magically know which results matter most to you?

The Scenario

Imagine you have a huge library of books and someone asks you to find the most useful books about "gardening." You try to look through each book one by one, guessing which might be best without any clear way to compare them.

The Problem

Manually checking each book is slow and confusing. You might miss the best ones or pick less useful ones because you have no clear way to measure how well each book matches the request.

The Solution

Elasticsearch gives each search result a relevance score called _score. This score tells you how well each result matches the search terms, so you can easily pick the best matches without guessing.

Before vs After
Before
results = []
for book in library:
    if 'gardening' in book.text:
        results.append(book)
# No ranking, just a list
After
results = elasticsearch.search(query='gardening')
# Each result has a _score showing relevance
What It Enables

It lets you quickly find and rank the most relevant information from huge data collections, saving time and improving accuracy.

Real Life Example

When you search for "best pizza places" on a review site, the results are ranked by how well they match your search, showing the tastiest and closest options first thanks to _score.

Key Takeaways

Manual searching is slow and unorganized.

_score ranks results by relevance automatically.

This helps find the best matches quickly and easily.