Passing varied parameters to BMI25 instead of 1 set

Continuing the discussion from Tweaking BM25 parameters efficiently:

I was wondering if its possible to pass multiple k1 and b values to BMI25 in order to determine the ideal parameters , instead of going through the pain of doing one at a time. Any help is much appreciated.

It should be possible to close an index, change settings and then reopen it. Alternatively, you can index the same field several times with different similarities. This will increase the index size, but you will be able to clearly see the difference in a single query:

PUT test
{
  "settings": {
    "number_of_shards": 1,
    "similarity": {
      "my_similarity_1": {
        "type": "BM25",
        "k1": 1,
        "b": 1
      },
      "my_similarity_2": {
        "type": "BM25",
        "k1": 0.5,
        "b": 0.5
      }
    }
  },
  "mappings": {
    "doc": {
      "properties": {
        "my_text": {
          "type": "text",
          "fields": {
            "sim_1": {
              "type": "text",
              "similarity": "my_similarity_1"
            },
            "sim_2": {
              "type": "text",
              "similarity": "my_similarity_2"
            }
          }
        }
      }
    }
  }
}

GET test/doc/_msearch
{}
{"query" : {"match" : {"my_text": "test terms"}}}
{}
{"query" : {"match" : {"my_text.sim_1": "test terms"}}}
{}
{"query" : {"match" : {"my_text.sim_2": "test terms"}}}

... or you can use combination of both. This way you can test several similarities at the same time for each open/close.

1 Like

see this issue. I’d love this feature!

Thanks you so much , worked like a charm...

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.