A FastAPI service that provides an API for a LanceDB vector database running in a Docker container.
- Create and manage LanceDB tables
- Add, search, and delete vector data
- Filter search results by metadata
- Containerized with Docker for easy deployment
- Docker
- Docker Compose
-
Clone this repository:
git clone <repository-url> cd lancedb
-
Start the service using Docker Compose:
docker-compose up -d
-
The API will be available at http://localhost:8002
- API documentation: http://localhost:8002/docs
- Alternative API documentation: http://localhost:8002/redoc
GET /api/tables- List all tablesPOST /api/tables- Create a new tablePOST /api/vectors- Add vectors to a tablePOST /api/search/{table_name}- Search for similar vectorsDELETE /api/vectors- Delete vectors from a tableGET /api/tables/{table_name}/info- Get information about a table
curl -X POST "http://localhost:8002/api/tables" \
-H "Content-Type: application/json" \
-d '{"table_name": "my_vectors", "vector_dimension": 384}'curl -X POST "http://localhost:8002/api/vectors" \
-H "Content-Type: application/json" \
-d '{
"table_name": "my_vectors",
"vectors": [
{
"id": "vec1",
"vector": [0.1, 0.2, 0.3, ...],
"metadata": {"category": "example", "source": "test"}
}
]
}'curl -X POST "http://localhost:8002/api/search/my_vectors" \
-H "Content-Type: application/json" \
-d '{
"vector": [0.1, 0.2, 0.3, ...],
"metadata_filter": {"category": "example"},
"limit": 5
}'curl -X DELETE "http://localhost:8002/api/vectors" \
-H "Content-Type: application/json" \
-d '{
"table_name": "my_vectors",
"ids": ["vec1"]
}'.
├── app/
│ ├── api/ # API endpoints
│ ├── db/ # Database client
│ ├── models/ # Data models
│ └── main.py # FastAPI application
├── data/ # LanceDB data (mounted volume)
├── Dockerfile
├── docker-compose.yml
└── requirements.txt
If you need to add new dependencies, update the requirements.txt file and rebuild the Docker image:
docker-compose build
docker-compose up -d