Zouzias
Zouzias

Reputation: 2360

BM25 Similarity in Elasticsearch

I want to change the default similarity of Elasticsearch to BM25.

According to

http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.4/index-modules-similarity.html

I only have to add the following line to the elasticsearch.yml file

index.similarity.default.type: BM25

However, BM25 has two input parameters k1 and b that I would like to set as well.

Does anyone know how to set these parameters?

Upvotes: 5

Views: 4939

Answers (2)

léa33
léa33

Reputation: 31

I found a really good page that explains the meaning of the parameters. It is here: https://www.elastic.co/guide/en/elasticsearch/guide/current/pluggable-similarites.html

Here is a snippet from that page:

k1 : This parameter controls how quickly an increase in term frequency results in term-frequency saturation. The default value is 1.2. Lower values result in quicker saturation, and higher values in slower saturation.

b : This parameter controls how much effect field-length normalization should have. A value of 0.0 disables normalization completely, and a value of 1.0 normalizes fully. The default is 0.75.

Upvotes: 3

Jay Rizzi
Jay Rizzi

Reputation: 4304

in the settings of your index , put in the similarity settings, like you would mappings

PUT /your_index/?pretty=1
{
       "settings": {
          "similarity": {
             "bm25-inverse-zero": {
                "type": "BM25",
                "b": 0
             }
          },
}

Upvotes: 2

Related Questions