In this lesson, you will learn how to create a vector index on existing data.

  1. Create an Embeddings model instance

  2. Create a Vector Store on all Talk nodes using the title and description properties. Save the embedding to the embedding property

  3. Grab a coffee and wait…​ ☕️

import { Neo4jVectorStore } from "@langchain/community/vectorstores/neo4j_vector";
import { OpenAIEmbeddings } from "@langchain/openai";
import { config } from "dotenv";

async function main() {

    config({ path: "./.env.local" });

    const embeddings = new OpenAIEmbeddings({
      openAIApiKey: process.env.OPEN_AI_API_KEY,

    const store = await Neo4jVectorStore.fromExistingGraph(embeddings, {
      url: process.env.NEO4J_URI,
      username: process.env.NEO4J_USERNAME,
      password: process.env.NEO4J_PASSWORD,
      nodeLabel: "Talk",
      textNodeProperties: ["title", "description"],
      indexName: "talk_embeddings_openai",
      embeddingNodeProperty: "embedding",

    await store.close();


Verify Challenge

Verifying the Test

Once you have executed the code, click the Verify button and we will check that the code has been executed successfully.


Well done!