- approximate nearest neighbor search
- Euclidean similarity and cosine similarity
- Hybrid search combining vector and keyword searches
Setup
To work with Neo4j Vector Index, you need to install theneo4j-driver
package:
npm
npm
Setup a Neo4j
self hosted instance with docker-compose
Neo4j
provides a prebuilt Docker image that can be used to quickly setup a self-hosted Neo4j database instance.
Create a file below named docker-compose.yml
:
docker-compose.yml
docker compose up
to start the container.
You can find more information on how to setup Neo4j
on their website.
Usage
One complete example of usingNeo4jVectorStore
is the following:
Use retrievalQuery parameter to customize responses
Instantiate Neo4jVectorStore from existing graph
Metadata filtering
Disclaimer ⚠️
Security note: Make sure that the database connection uses credentials that are narrowly-scoped to only include necessary permissions. Failure to do so may result in data corruption or loss, since the calling code may attempt commands that would result in deletion, mutation of data if appropriately prompted or reading sensitive data if such data is present in the database. The best way to guard against such negative outcomes is to (as appropriate) limit the permissions granted to the credentials used with this tool. For example, creating read only users for the database is a good way to ensure that the calling code cannot mutate or delete data. See the security page for more information.Related
- Vector store conceptual guide
- Vector store how-to guides