Scalar product sort for vector types

Hi all :slight_smile:

Presumably ES has some optimized scalar product scoring/sorting for textual relevance similarity scoring using documents' term vectors.

Is this same mechanism available for dense_vector and sparse_vector field types?

I'd hate to resort to using a script_score when ES probably has an optimized implementation!

Thanks!

the dotProduct and dotProductSparse functions within the script_score query are indeed what you are looking for I suppose. That's the function made available at the moment. See https://www.elastic.co/guide/en/elasticsearch/reference/7.x/query-dsl-script-score-query.html#_dense_vector_functions

Thanks @spinscale.

I suppose then there is no special support for this outside of a script_score?

In the past I have been disappointed by script_score performance, but I have not used ES7 yet. Does it get any better with ES7?

Thanks!

Even though there have been improvements, it is hard to tell if they are applied or sufficient for your use-case.

I'd personally just give it a shot and see how it works, if possible.

1 Like