0
Total Documents
0
With Embeddings
0%
Progress
-
Last Search (ms)
CSV Upload & Processing
Drop CSV file here or click to browse
Supports CSV files with agricultural data
CSV Processing Queue
Queue (Empty)
No CSV files in queue
Background Embedding Manager
Configuration
System Logs
Semantic Search
Quick Searches:
Search Results
0 resultsEnter a search query to see results
API Documentation
Complete API reference for the Semantic Search CSV Manager
Base URL
http://localhost:8080
Returns server status and available endpoints.
Request
GET /
Response
{
"message": "🚀 Semantic Search CSV Manager is running!",
"status": "healthy",
"embeddingsReady": true,
"endpoints": {
"uploadCSV": "POST /api/upload-csv",
"search": "POST /api/search",
"searchFallback": "POST /api/search-fallback",
"generateEmbeddings": "POST /api/generate-embeddings",
"status": "GET /api/status"
}
}
Get detailed system status including database stats and embedding progress.
Request
GET /api/status
Response
{
"status": "healthy",
"database": {
"connected": true,
"totalDocuments": 50000,
"documentsWithEmbeddings": 45000,
"embeddingProgress": "90.0%"
},
"embeddingsReady": true,
"isInitializing": false
}
Upload and process a CSV file containing agricultural data.
Request
POST /api/upload-csv
Content-Type:
multipart/form-data
Body: Form data with file field named
csvFile
Expected CSV Headers
Column | Type | Description |
---|---|---|
StateName | String | Name of the state |
DistrictName | String | Name of the district |
BlockName | String | Name of the block |
Season | String | Agricultural season |
Sector | String | Agricultural sector |
Category | String | Query category |
Crop | String | Crop name |
QueryType | String | Type of query |
QueryText | String | The actual query text |
KccAns | String | Answer/response text |
CreatedOn | Date | Creation date |
year | Number | Year |
month | Number | Month |
Success Response
{
"success": true,
"message": "CSV uploaded and processed successfully",
"totalProcessed": 49999,
"totalInserted": 49999
}
Error Response
{
"error": "CSV upload failed",
"message": "No file uploaded"
}
Perform semantic search using MongoDB Atlas vector search for fast results.
Request
POST /api/search
Content-Type:
application/json
Request Body Schema
{
"query": "string (required)", // Search query text
"topK": "number (optional)", // Number of results (default: 10)
"filters": { // Optional filters
"StateName": "string",
"DistrictName": "string",
"Category": "string",
"Season": "string",
"Crop": "string"
}
}
Example Request
{
"query": "Government schemes for farmers",
"topK": 5,
"filters": {
"StateName": "Maharashtra",
"Category": "Government Schemes"
}
}
Success Response
{
"success": true,
"query": "Government schemes for farmers",
"topK": 5,
"filters": { "StateName": "Maharashtra" },
"resultsCount": 5,
"searchTime": "45ms",
"results": [
{
"id": "64f1a2b3c4d5e6f7g8h9i0j1",
"similarity": 0.8945,
"StateName": "Maharashtra",
"DistrictName": "Pune",
"Category": "Government Schemes",
"QueryType": "Information",
"QueryText": "What government schemes are available?",
"KccAns": "PM-KISAN, PMFBY, and other schemes...",
"Crop": "Rice",
"Season": "Kharif",
"CreatedOn": "2024-01-15T10:30:00.000Z"
}
]
}
Perform semantic search using manual cosine similarity calculation for reliable results when vector search is unavailable.
Request
POST /api/search-fallback
Content-Type:
application/json
Body: Same as
/api/search
Response
Same format as /api/search
but may take longer to
process.
Start the asynchronous process of generating embeddings for all documents in the database.
Request
POST /api/generate-embeddings
Content-Type:
application/json
Body: Empty or
{}
Response
{
"success": true,
"message": "Embedding generation started. Check /api/status for progress.",
"note": "This is an asynchronous process that may take several minutes."
}
/api/status
endpoint.
Common Error Codes
Status Code | Error Type | Description |
---|---|---|
400 | Bad Request | Missing required parameters or invalid request format |
404 | Not Found | Endpoint does not exist |
500 | Internal Server Error | Server error during processing |
503 | Service Unavailable | Semantic search module not available |
Rate Limits & Performance
- CSV Upload: Max file size 50MB
- Search Requests: No rate limit (local server)
- Vector Search: ~50-200ms response time
- Fallback Search: ~500-2000ms response time
- Embedding Generation: ~1-5 minutes for 50k documents
cURL Examples
Search Request
curl -X POST http://localhost:8080/api/search \
-H "Content-Type: application/json" \
-d '{
"query": "crop disease management techniques",
"topK": 10,
"filters": {
"StateName": "Karnataka",
"Category": "Disease Management"
}
}'
Status Check
curl -X GET http://localhost:8080/api/status
Generate Embeddings
curl -X POST http://localhost:8080/api/generate-embeddings \
-H "Content-Type: application/json" \
-d '{}'