0

I have the following script search query:

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;"
       }
     }
   }
 }
}

Since the vectors are pre-normalized, I have written this to get the dot product. I have tested this on dummy data, it works but on the actual data it throws a connection time out error. 'test1' is the array with which I am taking dot product.

es.search(index="images", doc_type='image', body=bdy)
  • Do you have an error in the ES server logs? Can you show a sample value for `test1`? – Val Jul 25 '18 at 06:05
  • @Val test1 is a vector similar to this '[0.0377055853605,0.000859705265611,-0.0299785286188,-0.00769839854911]', just number of dimensions are 512. The error I get is ConnectionTimeout: ConnectionTimeout caused by - ReadTimeoutError(HTTPConnectionPool(host='localhost', port=9200): Read timed out. (read timeout=10)) – Celebrimbor_mak Jul 25 '18 at 06:08

0 Answers0