Skip to content

An e-commerce application showcasing advanced vector search capabilities using Weaviate and Java Spring Boot.

License

Notifications You must be signed in to change notification settings

weaviate-tutorials/vector-store

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vector Shop - AI-Powered E-commerce with Weaviate

A demonstration e-commerce application showcasing advanced vector search capabilities using Weaviate Java Client v6, Spring Boot 3.x, and vanilla JavaScript.

Weaviate Java Client v6

Features

  • 3 Search Types:

    • Keyword Search (BM25): Traditional keyword-based search
    • Similarity Search (Vector): Semantic search using text embeddings
    • Hybrid Search: Combines BM25 and vector search for best results
  • 20 Product Catalog: Pre-loaded with diverse items across clothes, shoes, and accessories

  • Modern UI: Clean, responsive interface with tabbed search modes

  • Real-time Results: Instant search results with product cards

  • Weaviate Client v6: Built with the latest Weaviate Java Client v6 API

Prerequisites

  1. Java 21 and Maven+
  2. Weaviate Cloud free Sandbox cluster
  3. Optional for running Weaviate locally: Docker Compose

Setting Up Weaviate (optional)

Docker Compose

The project includes a docker-compose.yml file configured with Weaviate 1.34.0 and text2vec-transformers.

Start Weaviate:

docker-compose up -d

This will start:

  • Weaviate on port 8080 (HTTP) and 50051 (gRPC)
  • text2vec-transformers inference service for text vectorization

Wait about 30-60 seconds for all services to initialize.

Verify Weaviate is running:

curl http://localhost:8080/v1/.well-known/ready

You should see: {"status":"healthy"}

Running the application

  1. Clone or navigate to the project directory:
cd vector-shop
  1. Build the project:
mvn clean install
  1. Run the application:
mvn spring-boot:run

The application will:

  • Start on port 8081
  • Connect to Weaviate on localhost:8080
  • Automatically create the schema
  • Import 20 products from products.json
  1. Access the application:

Open your browser and navigate to:

http://localhost:8081

Project structure

vector-shop/
├── src/
│   └── main/
│       ├── java/com/example/vectorshop/
│       │   ├── VectorShopApplication.java
│       │   ├── config/
│       │   │   └── WeaviateConfig.java
│       │   ├── controller/
│       │   │   ├── SearchController.java
│       │   │   └── SetupController.java
│       │   ├── model/
│       │   │   ├── ConnectionRequest.java
│       │   │   ├── GenerativeSearchResponse.java
│       │   │   ├── Product.java
│       │   │   └── SetupResponse.java
│       │   └── service/
│       │       ├── SearchService.java
│       │       └── SetupService.java
│       └── resources/
│           ├── application.properties
│           ├── products.json
│           └── static/
│               ├── index.html
│               ├── script.js
│               ├── styles.css
│               └── code/ (code snippet examples)
├── docker-compose.yml
├── pom.xml
├── LICENSE.md
└── README.md

API Endpoints

  • GET /api/search/keyword?query={query} - Keyword search
  • GET /api/search/similarity?query={query} - Similarity search
  • GET /api/search/hybrid?query={query} - Hybrid search
  • GET /api/search/image?imageUrl={url} - Image search
  • GET /api/search/generative?query={query} - Generative search

Configuration

Edit src/main/resources/application.properties:

# Server Configuration
server.port=8081

# Weaviate Configuration
weaviate.host=localhost
weaviate.port=8080
weaviate.scheme=http

Technologies Used

  • Backend: Java 21, Spring Boot 3.2.1, Maven
  • Vector Database: Weaviate 1.34.0
  • Vectorizers: text2vec-weaviate (for Weaviate Cloud) & text2vec-transformers (for local instance)
  • Frontend: HTML5, CSS3, JavaScript
  • Libraries:
    • Weaviate Java Client v6 (6.0.0-M2)
    • Jackson (JSON processing)
    • Lombok (code generation)

Example Searches

  • Keyword: "blue jeans", "running shoes", "winter"
  • Similarity: "comfortable casual wear", "athletic footwear"
  • Hybrid: "stylish accessories for summer"

Troubleshooting

Port 8080 already in use ```bash # Find and stop the process lsof -ti:8080 | xargs kill -9 ```
Port 8081 already in use

Edit src/main/resources/application.properties and change:

server.port=8082
Data not loading

Check the application logs for errors. The seeder runs automatically on startup.

Weaviate not responding ```bash # Restart Weaviate docker-compose restart weaviate ```
Connection Refused Error
  • Ensure Weaviate is running on port 8080
  • Check Docker containers: docker ps
No Search Results
  • Check Weaviate logs: docker logs weaviate
  • Verify data was seeded in application logs
Generative Search Not Working
  • This feature requires OpenAI API key
  • Error messages will indicate if the API key is missing or invalid
Image Search Not Working
  • Image search in v6 requires base64-encoded images
  • URL-based image search is not directly supported in the current implementation

License

MIT License - Free to use and modify.

About

An e-commerce application showcasing advanced vector search capabilities using Weaviate and Java Spring Boot.

Resources

License

Stars

Watchers

Forks