Search Service API
π
A comprehensive search and indexing REST API built with Java, Spring Boot, and Elasticsearch. Provides full-text search, faceted search, filtering, and advanced query capabilities across all indexed content.
Features
| Feature | Description | Icon |
|---|---|---|
| Full-Text Search | Powerful full-text search with relevance ranking | π |
| Faceted Search | Navigate results with facets and filters | π·οΈ |
| Real-Time Indexing | Index documents as they're created or updated | β‘ |
| Advanced Queries | Boolean, wildcard, range, and phrase queries | π |
| Autocomplete | Type-ahead suggestions while typing | π‘ |
| Analytics | Track search queries and user behavior | π |
| Multi-Tenant Support | Isolate indices per tenant | π’ |
Architecture Overview
flowchart TD
A[Client] -->|REST API| B(SearchController)
B --> C[SearchService]
C --> D[IndexManager]
C --> E[QueryBuilder]
D --> F[Elasticsearch]
E --> F
B --> G[AnalyticsService]
G --> H[(PostgreSQL)]
Hold "Alt" / "Option" to enable pan & zoom
API Endpoints
Note: Real API endpoints to be provided and included here.
| Method | Endpoint | Description | Notes/Parameters |
|---|---|---|---|
| POST | /api/v1/search |
Execute search query | tenantId header, query params |
| GET | /api/v1/search |
Execute search query (GET) | q, filters, facets, sort |
| POST | /api/v1/search/index |
Index document | Document content |
| GET | /api/v1/search/autocomplete |
Get autocomplete suggestions | Query prefix |
Sequence: Execute Search Query
sequenceDiagram
participant U as User
participant API as SearchController
participant S as SearchService
participant Q as QueryBuilder
participant E as Elasticsearch
participant A as AnalyticsService
U->>API: GET /search (q=query, filters)
API->>S: execute search
S->>Q: build query
Q-->>S: query DSL
S->>E: execute search
E-->>S: results
S->>A: log search query
A-->>S: logged
S-->>API: SearchResponse
API-->>U: 200 OK + results with facets
Hold "Alt" / "Option" to enable pan & zoom
Database Schema
erDiagram
search_indices {
UUID id PK
UUID tenant_id
VARCHAR index_name
VARCHAR index_type
INTEGER document_count
DECIMAL size_mb
TIMESTAMP created
TIMESTAMP updated
}
indexed_documents {
UUID id PK
UUID tenant_id
UUID index_id FK
VARCHAR document_id
TEXT document_content
JSON metadata
TIMESTAMP indexed_at
TIMESTAMP updated_at
}
search_queries {
UUID id PK
UUID tenant_id
VARCHAR query_text
INTEGER result_count
INTEGER response_time_ms
VARCHAR user_id
TIMESTAMP executed_at
}
search_analytics {
UUID id PK
UUID tenant_id
VARCHAR metric_name
DECIMAL metric_value
VARCHAR dimension
DATE date
TIMESTAMP created
}
search_indices ||--o{ indexed_documents : "contains"
Hold "Alt" / "Option" to enable pan & zoom
Getting Started
Prerequisites
- Java 17+
- Elasticsearch 7.x+
- PostgreSQL
- Gradle
Setup
git clone https://github.com/Olanna-tech/search-service-java.git
cd search-service-java
./gradlew build
Database & Elasticsearch
- Configure PostgreSQL credentials in
src/main/resources/application.yml. - Configure Elasticsearch connection details.
- Run Flyway migrations (auto on startup).
Run
./gradlew bootRun
Configuration
Set the following environment variables in application.yml:
search:
elasticsearch-host: localhost
elasticsearch-port: 9200
elasticsearch-cluster: elasticsearch
bulk-size: 1000
index-refresh-interval: 1s
analytics-enabled: true
autocomplete-enabled: true
Contributing
Pull requests are welcome! For major changes, please open an issue first.
License
Contact
- Olanna
- support@Olanna.tech