Elastic search sub_searches with knn and rrf

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}},
                }

Hey there @avranjan thanks for the question! In the case of knn as a query, k is not sent in directly as k is determined by size.

Thanks @Kathleen_DeRusso . Is there a recommended way to dynamically configure below properties in elastic with vector search?

k
num_candidates
window_size
rank_constant

There's no hard and fast rule, but in general if you want more accuracy use a higher num candidates and if you want more speed use a lower num candidates.