Is there an example to use sub_searches with knn? Why the k value is not allowed in query? Here is an example:
{
"_source": {"excludes": ["vector", "elser_vector"]},
"size": 1000,
"sub_searches": [
{
"query": {
"knn": {
"field": "vector",
"filter": [
{
"terms": {
"metadata.document_id": [1,2,3]
}
}
],
"query_vector": self.get_embedding().embed_query(
"Who is the president of US?"
),
"k" : 100 # k doesn't work
"num_candidates": 1.5 * k, # k doesn't work here
}
}
},
{
"query": {
"bool": {
"must": {
"text_expansion": {
"elser_vector": {
"model_id": ".elser_model_2_linux-x86_64",
"model_text": "Who is the president of US?",
},
}
},
"filter": [
{
"terms": {
"metadata.document_id": [1, 2 ,3]
}
}
],
}
}
},
{
"query": {
"bool": {
"must": {
"match": {"text": {"query": "Who is the president of US?"}},
},
"filter": [
{
"terms": {
"metadata.document_id": [1,2,3]
}
}
],
}
}
},
],
"rank": {"rrf": {"window_size": 1000, "rank_constant": 100}},
}