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

[source, js]
----
const response = await client.indices.create({
  index: "retrievers_example",
  settings: {
    number_of_shards: 1,
  },
  mappings: {
    properties: {
      vector: {
        type: "dense_vector",
        dims: 3,
        similarity: "l2_norm",
        index: true,
        index_options: {
          type: "flat",
        },
      },
      text: {
        type: "text",
      },
      year: {
        type: "integer",
      },
      topic: {
        type: "keyword",
      },
      timestamp: {
        type: "date",
      },
    },
  },
});
console.log(response);

const response1 = await client.index({
  index: "retrievers_example",
  id: 1,
  document: {
    vector: [0.23, 0.67, 0.89],
    text: "Large language models are revolutionizing information retrieval by boosting search precision, deepening contextual understanding, and reshaping user experiences in data-rich environments.",
    year: 2024,
    topic: ["llm", "ai", "information_retrieval"],
    timestamp: "2021-01-01T12:10:30",
  },
});
console.log(response1);

const response2 = await client.index({
  index: "retrievers_example",
  id: 2,
  document: {
    vector: [0.12, 0.56, 0.78],
    text: "Artificial intelligence is transforming medicine, from advancing diagnostics and tailoring treatment plans to empowering predictive patient care for improved health outcomes.",
    year: 2023,
    topic: ["ai", "medicine"],
    timestamp: "2022-01-01T12:10:30",
  },
});
console.log(response2);

const response3 = await client.index({
  index: "retrievers_example",
  id: 3,
  document: {
    vector: [0.45, 0.32, 0.91],
    text: "AI is redefining security by enabling advanced threat detection, proactive risk analysis, and dynamic defenses against increasingly sophisticated cyber threats.",
    year: 2024,
    topic: ["ai", "security"],
    timestamp: "2023-01-01T12:10:30",
  },
});
console.log(response3);

const response4 = await client.index({
  index: "retrievers_example",
  id: 4,
  document: {
    vector: [0.34, 0.21, 0.98],
    text: "Elastic introduces Elastic AI Assistant, the open, generative AI sidekick powered by ESRE to democratize cybersecurity and enable users of every skill level.",
    year: 2023,
    topic: ["ai", "elastic", "assistant"],
    timestamp: "2024-01-01T12:10:30",
  },
});
console.log(response4);

const response5 = await client.index({
  index: "retrievers_example",
  id: 5,
  document: {
    vector: [0.11, 0.65, 0.47],
    text: "Learn how to spin up a deployment of our hosted Elasticsearch Service and use Elastic Observability to gain deeper insight into the behavior of your applications and systems.",
    year: 2024,
    topic: ["documentation", "observability", "elastic"],
    timestamp: "2025-01-01T12:10:30",
  },
});
console.log(response5);

const response6 = await client.indices.refresh({
  index: "retrievers_example",
});
console.log(response6);
----
