diff --git a/comps/vectorstores/arango/README.md b/comps/vectorstores/arango/README.md new file mode 100644 index 0000000000..7af35304e9 --- /dev/null +++ b/comps/vectorstores/arango/README.md @@ -0,0 +1,58 @@ +# 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 arangodb -p 8529:8529 -e ARANGO_ROOT_PASSWORD=openSesame arangodb/arangodb:3.12.4 --experimental-vector-index true +``` + +## 2. Create a Vector Index + +**Using `arangosh`**: + +```bash +127.0.0.1:8529@_system > db.myCollection.ensureIndex( + { + name: "my-vector-index", + type: "vector", + fields: ["embedding"] + params: { metric: "cosine", dimension: 1024, nLists: 100 } + } +) +``` + +**Using the `python-arango` driver**: + +```python +from arango import ArangoClient + +db = ArangoClient(hosts="http://localhost:8529").db('_system', username='root', password='openSesame') + +db.collection("myCollection").add_index( + { + "name": "my-vector-index", + "type": "vector", + "fields": ["embeddings"], + "params": { + "metric": "cosine", + "dimension": 1024, + "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.embedding, query_embedding) + SORT score DESC + LIMIT 5 + RETURN {doc, score} +``` \ No newline at end of file diff --git a/comps/vectorstores/arango/__init__.py b/comps/vectorstores/arango/__init__.py new file mode 100644 index 0000000000..916f3a44b2 --- /dev/null +++ b/comps/vectorstores/arango/__init__.py @@ -0,0 +1,2 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 diff --git a/comps/vectorstores/arango/docker-compose.yml b/comps/vectorstores/arango/docker-compose.yml new file mode 100644 index 0000000000..c51a45f046 --- /dev/null +++ b/comps/vectorstores/arango/docker-compose.yml @@ -0,0 +1,18 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +services: + arangodb: + image: arangodb/arangodb:3.12.4 + container_name: arangodb + ports: + - "8529:8529" + environment: + - ARANGO_ROOT_PASSWORD=openSesame + volumes: + - arango_data:/var/lib/arangodb3 + command: ["--experimental-vector-index=true"] + +volumes: + arango_data: + driver: local \ No newline at end of file