Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArangoDB: Vector Store #13

Open
wants to merge 2 commits into
base: arangodb
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions comps/vectorstores/arango/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Start ArangoDB server

**Additional Links**:
- https://arangodb.com/2024/11/vector-search-in-arangodb-practical-insights-and-hands-on-examples/

## 1. Start ArangoDB via Docker

```bash
docker run -d --name arango -p 8529:8529 -e ARANGO_ROOT_PASSWORD=test arangodb/arangodb:3.12
```

## 2. Create a Vector Index

**Using `arangosh`**:

```bash
127.0.0.1:8529@_system > db.myCollection.ensureIndex(
{
name: "my-vector-index",
type: "vector",
fields: ["embeddings"]
params: { metric: "cosine", dimension: 128, nLists: 100 }
}
```

**Using the `python-arango` driver**:

```python
from arango import ArangoClient

db = ArangoClient().db('_system', username='root', password='test')

db.collection("myCollection").add_index(
{
"name": "my-vector-index",
"type": "vector",
"fields": ["embeddings"],
"params": {
"metric": "cosine",
"dimensions": 128,
"nLists": 100,
},
}
)
```

## 3. Use the Vector Index via the Arango Query Language (AQL)

```bash
LET query_embedding = [0.1, 0.3, 0.5, …]

FOR doc IN myCollection
LET score = APPROX_NEAR_COSINE(doc.embeddings, query_embedding)
SORT score DESC
LIMIT 5
RETURN {doc, score}
```
2 changes: 2 additions & 0 deletions comps/vectorstores/arango/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
11 changes: 11 additions & 0 deletions comps/vectorstores/arango/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

services:
arango:
image: arangodb/arangodb:3.12
container_name: arangodb
ports:
- 8529:8529
environment:
ARANGO_ROOT_PASSWORD: ${ARANGO_ROOT_PASSWORD}