opendistro-for-elasticsearch / k-NN

🆕 A machine learning plugin which supports an approximate k-NN search algorithm for Open Distro.

Home Page:https://opendistro.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Boost Factor in KNN

SourabhTirodkar opened this issue · comments

Is there a possibility of including a boost factor for KNN search ?

Hi @SourabhTirodkar,

boost to kNN search can be achieved through function_score. In the below example i am boosting the score by 2.


curl -X POST "localhost:9200/myindex/_search" -H 'Content-Type: application/json' -d'
{
  "size" : 2,
  "query": {
    "bool": {
      "must": [
        {
          "function_score": {
            "query": {
              "knn": {
                  "my_vector": {
                  "vector": [7, 8],
                  "k": 2
                  }       
              }
          },
            "weight": 2
          }
        },
      ]
    }
  }
}
'