// This file is autogenerated, DO NOT EDIT
// Use `node scripts/generate-docs-examples.js` to generate the docs examples

[source, js]
----
const response = await client.searchApplication.put({
  name: "my_search_application",
  search_application: {
    indices: ["index1"],
    template: {
      script: {
        lang: "mustache",
        source:
          '\n      {\n          "knn": {\n            "field": "{{knn_field}}",\n            "query_vector": {{#toJson}}query_vector{{/toJson}},\n            "k": "{{k}}",\n            "num_candidates": {{num_candidates}}\n          },\n          "fields": {{#toJson}}fields{{/toJson}}\n      }\n      ',
        params: {
          knn_field: "image-vector",
          query_vector: [],
          k: 10,
          num_candidates: 100,
          fields: ["title", "file-type"],
        },
      },
    },
  },
});
console.log(response);
----
