Hi there!
Did I understand your intention correctly: you want to go through all documents, and apply cosine similarity function to them. Then you also have a query and for the documents that match a query, you want to calculate score for this query. Then you want to combine these two scores: from a cosine similarity and a query?
Currently, you can do that with a bool query using should clauses like this:
GET my_index/_search
{
"query": {
"bool": {
"should" : [
{
"match": {
"my_text": {
"query": "abc"
}
}
},
{
"script_score" : {
"query" : {"match_all" : {}},
"script" : {
"source": "50 * cosineSimilarity(params.query_vector, doc['my_vector']) + 1.0",
"params": {
"query_vector": [0, 0, 1]
}
}
}
}
]
}
}
}
This will give you a sum of scores: score1 + score2. You can also apply boost for any query.
We also have a plan to develop a compound query that will give you an option to combine scores of queries not only through sum option. But this is not available yet.