With what function does Elasticsearch 7.5 calculate a default score? - elasticsearch

With what function does Elasticsearch 7.5 calculate a default score? An explanation i found here (https://www.compose.com/articles/how-scoring-works-in-elasticsearch/), but it work only for old versions as i understand, because query norm was removed in lucene 7.0.

Prior to lucene 6.X, ES was using tf/idf as its default scoring algorithm, which they changed to BM25 once they started using Lucene 6.X and higher.
ES 7.5.1 uses Lucene 8.3.1 and they are using BM25 as their default scoring algorithm.
More details about the announcement of this change and other important links are below:
BM25 announcement:- https://www.elastic.co/elasticon/conf/2016/sf/improved-text-scoring-with-bm25
BM25 details and internals :- https://speakerdeck.com/elastic/improved-text-scoring-with-bm25
How to configure different scoring algo : https://www.elastic.co/guide/en/elasticsearch/reference/current/similarity.html

Related

How does calculating relevance scoring in Elasticsearch differ from Couchbase?

I wonder whether relevance score in elasticsearch has differences with couchbase or not?
As per this 2019 couchbase thread, it looks like they are still using the tf/idf for scoring, while Elasticsearch used to have the same algorithm but now moved to BM25 algorithm for score calculation from 5.0.
Note: TF/IDF is a very popular algorism for calculating the relevance score and based on term frequency and inverse document frequency, while BM25 is the latest and improvised form based on probabilistic scoring more details about them can be found here and here.
Note: As in the question, it's not mentioned for what purpose you are comparing both the relevance of the system, My two cents are if you are building a full-blown search system and relevance matters for you, then you should choose Elasticseaech whose primary function is to search and has a lot of flexibility in choosing different algorithm and different ways to define the scoring mechanism, which is not present in NoSQL solution like Couchbase.

Issue with results after upgrading elastic search

I am upgrading my elasticsearch from 2.2 to 7.1 and I am maintaining both the instances and I am trying to compare the results on the new version and old version by making the same search queries.
Note: I have not changed the mappings, settings or querying logic
My results are almost the same but vary a little in scoring. Is it expected? though the documents, mappings, settings and query logic are the same?
Elasticsearch 2.x version uses the tf/idf for scoring and this ES doc explains it in details.
While ES 7.X uses the improved BM25 algorithm for score calculation. this is another nice article from ES which explains it in details.
In short yes, there are significant changes in the scoring formula of ES 2.X and 7.X as underlying algorithm changed itself and even though you have everything else same like documents, mappings, settings and query, still you will be having a different score.
You can use the explain API on your query to understand the score of documents returned by the query.

How cosine similarity differs from Okapi BM25?

I'm conducting a research using elasticsearch. I was planning to use cosine similarity but I noted that it is unavailable and instead we have BM25 as default scoring function.
Is there a reason for that? Is cosine similarity improper for querying documents? Why was BM25 chosen as default?
Thanks
Longtime elasticsearch use TF/IDF algorithm to find similarity in queries. But number versions ago is changed to BM25 as more efficient. You can read the information in the documentation. And good article explains what is elastic search and how to the similarity in ES.
You can also write a custom algorithm to elasticsearch. Here a good article about how to do.

Custom plugin for Elasticsearch to change the default relevancy

I am currently using Elasticsearch and there are few things I have noticed about the ranks of the search results, which led me to think about whether there is a way to create plugins/script for ES, which can be used to modify the current scoring algorithm?
You can either write a custom Java plugin for that, use function score queries, or scripted similarity (which just came out this week).
If you can I would use the two later methods; writing a custom plugin should only be required very rarely.
You can refer to the blog A Gentle Intro to Function Scoring which describes ranking of videos on a website using a combination of textual relevance and the videos popularity on a site.
To modify the scoring algorithm the Elasticsearch provides script_score, function_score and Decay Function.

new approach of indexing in Elasticsearch

I want to define a new approach of indexing in Elasticsearch so i will edit tf idf method .
where to find TF-IDF elasticsearch implementation?
what are the packages in elasticsearch source code that i need to manipulate to implement the new approach?
The TF/IDF similarity algorithm is implemented in Lucene, however, there are ways to define another similarity algorithm to be used inside Elasticsearch via the similarity module. In addition to TF/IDF, there are currently 7 more similarities supported:
BM25
Classic similarity
DFR similarity
DFI similarity
IB similarity
LM Dirichlet similarity
LM Jelinek Mercer similarity
Each of them has different parameters that you can tune. Maybe it'd be a good idea to test each of them before venturing into creating your own.
More info about the available Lucene similarity algorithms: https://lucene.apache.org/core/6_5_0/core/org/apache/lucene/search/similarities/Similarity.html

Resources