Is there any way to do batch inference(matrix compute) using cosineSimilarity?

In some scenarios, I want to calculate the cosine similarity between M dense_vectors and all the stored dense_vectors. This can be achieved by calling the cosineSimilarity function for M times like this:
"script": {
    "source": "cosineSimilarity(params.query_vector, doc['vector']) + 1",
    "params": {
         "query_vector": query_vector,
What I want to ask is:
1. Will it be faster to batch these M dense_vectors and then do matrix operations(like numpy in python) for only one time?
2. Does es support batch inference with cosineSimilarity ?

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