CompatibilityOnly available on Node.js.
Setup
This module expects an endpoint and deployed index already created as thecreation time takes close to one hour. To learn more, see the LangChain python
documentation Create Index and deploy it to an Endpoint.
- You are logged into an account (using
gcloud auth application-default login
) permitted to that project. - You are running on a machine using a service account that is permitted to the project.
- You have downloaded the credentials for a service account that is permitted
to the project and set the
GOOGLE_APPLICATION_CREDENTIALS
environment variable to the path of this file.
npm
npm
Usage
Initializing the engine
When creating theMatchingEngine
object, you’ll need some information about
the matching engine configuration. You can get this information from the Cloud Console
for Matching Engine:
- The id for the Index
- The id for the Index Endpoint
InMemoryDocstore
is ok for
initial testing, you will want to use something like a
GoogleCloudStorageDocstore to store it more permanently.
Adding documents
Querying documents
Doing a straightforward k-nearest-neighbor search which returns all results is done using any of the standard methods:Querying documents with a filter / restriction
We can limit what documents are returned based on the metadata that was set for the document. So if we just wanted to limit the results to those with a red color, we can do:Deleting documents
Deleting documents are done using ID.Related
- Vector store conceptual guide
- Vector store how-to guides