Setup
- Sign up for an API key in the Momento Console.
-
Install the SDK for your environment.
2.1. For Node.js:
2.2. For browser or edge environments:npmnpm
-
Setup Env variables for Momento before running the code
3.1 OpenAI
3.2 Momento
Usage
npm
Index documents using fromTexts and search
This example demonstrates using the fromTexts method to instantiate the vector store and index documents.
If the index does not exist, then it will be created. If the index already exists, then the documents will be
added to the existing index.
The ids are optional; if you omit them, then Momento will generate UUIDs for you.
Index documents using fromDocuments and search
Similar to the above, this example demonstrates using the fromDocuments method to instantiate the vector store and index documents.
If the index does not exist, then it will be created. If the index already exists, then the documents will be
added to the existing index.
Using fromDocuments allows you to seamlessly chain the various document loaders with indexing.
Search from an existing collection
Related
- Vector store conceptual guide
- Vector store how-to guides
Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.