I am trying to filter out results of a cosine similarity using terms
. This is the query I am using?
{
"size": 15,
"query": {
"function_score": {
"query": {
"bool": {
"must": {
"terms": {
"id_": [
"1","2", "999"
]
}
}
}
}
},
"script_score": {
"script": {
"source": "cosineSimilarity(params.query_vector, 'emb_vector') + 1.0",
"params": {
"query_vector": [
]
}
}
}
},
"_source": {
"includes": [
"title",
"body",
"id_",
"text"
]
}
}
What I want is only those docs with the id 1,2 or 999 be returned. But, it is throwing the following error:
"reason": "[function_score] malformed query, expected [END_OBJECT] but found [FIELD_NAME]",
"line": 17,
"col": 9
What am I doing wrong?
Here is the mapping:
{"mappings": {
"properties": {
"id_": {
"type": "text"
},
"emb_vector": {
"type": "dense_vector",
"dims": 768
},
"title": {
"type": "text"
},
"text": {
"type": "text"
}
}
}
}