0

我有以下脚本搜索查询:

bdy = {
 "query": {
   "function_score": {
     "script_score": {
       "script": {
         "lang": "painless",
         "inline": "def test = "+test1+"; float total = 0; for (int i = 0; i < doc['embedding_vector'].length; i++) { total += doc['embedding_vector'][i]*test[i]; } return total;"
       }
     }
   }
 }
}

由于向量是预先归一化的,我写了这个来得到点积。我已经在虚拟数据上对此进行了测试,它可以工作,但是在实际数据上它会引发连接超时错误。'test1' 是我使用点积的数组。

es.search(index="images", doc_type='image', body=bdy)
4

0 回答 0