Sorting document by the number of keywords found

Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):

Describe the issue:
I got documents and I want to search them for 1 or more words/phrases.
I got results sorted by _score value. But It is not what I am looking for. I want documents with higher number of keywords found to be ranked higher.
Example: I am looking for a 2 keywords “fluffy” and “cat”
What I need: I want the document with total count of found words “fluffy” and “cat” equals 20 to be ranked higher that a document with the number of keywords equal 15. 15 should be above one with 12 keywords etc.

Configuration:

Relevant Logs or Screenshots:

I found the solution myself. I had to change the standard Okapi BM25 algorithm setting to one below. This has to be done when creating index.

BM25 params:

  • k1 - is a tuning parameter (usually set between 1.2 and 2.0) it controls the term frequency saturation. Increasing k1 increases the saturation effect.

  • b - is another tuning parameter (usually set around 0.75) – it controls the length normalization. A value of 1.0 fully normalizes document length, while 0.0 ignores length normalization.

     {
     "settings": {
     "index": {
       "similarity": {
         "default": {
           "type": "BM25",
           "k1": 2.0,
           "b": 0.0
         }
       }
     }
    

    }