lior-k / fast-elasticsearch-vector-scoring

Score documents using embedding-vectors dot-product or cosine-similarity with ES Lucene engine
Apache License 2.0
395 stars 112 forks source link

How to query for two vectors with different weights? #37

Closed thereye closed 4 years ago

thereye commented 4 years ago

This plugin is great for me. I have two vectors: image_vector and text_vector, and I added this two vectors in my ES index.

The question is how to query two vectors at the same time with different weight(since the image vector is more important than text vector)? thanks very much!

lior-k commented 4 years ago

Hi @thereye, I'm glad this plug-in helps you. Regarding your question, you can combine multiple functions in a function_score query. See this documentation: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html

Just wrap the script_score with "functions: [•••]" and then you can have multiple script_score with different boosts for each.

Hope this helps, Lior.

thereye commented 4 years ago

Hi @thereye, I'm glad this plug-in helps you. Regarding your question, you can combine multiple functions in a function_score query. See this documentation: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html

Just wrap the script_score with "functions: [•••]" and then you can have multiple script_score with different boosts for each.

Hope this helps, Lior.

Thanks for your reply, that helps me!