Spring Boot API for storing and querying semantically similar text using vector embeddings and cosine distance, powered by Ollama and pgvector.
- Java 21+
- Docker & Docker Compose
- Ollama (local LLM inference)
- https://ollama.com/download
- curl -fsSL https://ollama.com/install.sh | sh
- ollama run nomic-embed-text
☑️ Ollama API will be available at http://localhost:11434
docker-compose up -d
- Host: localhost
- Port: 5432
- User: search
- Password: search
- Database: search
If the schema isn't auto-created, run this:
CREATE EXTENSION IF NOT EXISTS vector;
CREATE TABLE text (
id UUID PRIMARY KEY,
content TEXT,
embedding vector(768)
);
CREATE INDEX idx_text_embedding_hnsw
ON text USING hnsw (embedding vector_cosine_ops);
./gradlew bootRun
./gradlew build
java -jar build/libs/semantic-search-*.jar
- API Base: http://localhost:8085
- Swagger UI: http://localhost:8085/swagger-ui.html
POST /text → Store a new text with its embedding
POST /search → Search for similar texts