|
| 1 | +# Random Job Endpoint |
| 2 | + |
| 3 | +**Route:** `GET /v1/random/` |
| 4 | + |
| 5 | +## Description |
| 6 | + |
| 7 | +Returns a single random job from the Solr `job` core. Useful for discovery, widgets, or "job of the day" features. |
| 8 | + |
| 9 | +## How It Works |
| 10 | + |
| 11 | +1. Queries Solr with `q=*:*&rows=0` to get the total number of indexed jobs (`numFound`). |
| 12 | +2. Picks a random offset: `start = rand(0, numFound - 1)`. |
| 13 | +3. Fetches one document at that offset: `q=*:*&rows=1&start={random}&omitHeader=true`. |
| 14 | +4. Returns the job fields mapped to the peviitor Job Model Schema. |
| 15 | + |
| 16 | +## Response Format |
| 17 | + |
| 18 | +### Success (200) |
| 19 | + |
| 20 | +```json |
| 21 | +{ |
| 22 | + "title": "Inginer IT", |
| 23 | + "company": "COMPANY SRL", |
| 24 | + "location": ["București", "Cluj-Napoca"], |
| 25 | + "workmode": "remote", |
| 26 | + "url": "https://example.com/job/123", |
| 27 | + "salary": "5000-8000 RON", |
| 28 | + "tags": ["python", "java"], |
| 29 | + "cif": "12345678", |
| 30 | + "date": "2026-06-15T10:00:00Z", |
| 31 | + "status": "published" |
| 32 | +} |
| 33 | +``` |
| 34 | + |
| 35 | +### No Jobs Found (404) |
| 36 | + |
| 37 | +```json |
| 38 | +{ |
| 39 | + "error": "No jobs found" |
| 40 | +} |
| 41 | +``` |
| 42 | + |
| 43 | +### Service Unavailable (503) |
| 44 | + |
| 45 | +```json |
| 46 | +{ |
| 47 | + "error": "Job core unavailable", |
| 48 | + "details": "PROD_SERVER not set" |
| 49 | +} |
| 50 | +``` |
| 51 | + |
| 52 | +## Response Fields |
| 53 | + |
| 54 | +| Field | Type | Description | |
| 55 | +|------------|----------|--------------------------------------------------| |
| 56 | +| title | string | Job title | |
| 57 | +| company | string | Company name (uppercase) | |
| 58 | +| location | string[] | Array of cities | |
| 59 | +| workmode | string | "remote", "on-site", or "hybrid" | |
| 60 | +| url | string | Full URL to the job detail page | |
| 61 | +| salary | string | Salary interval with currency (e.g. "5000-8000 RON") | |
| 62 | +| tags | string[] | Array of skill tags | |
| 63 | +| cif | string | CIF/CUI | |
| 64 | +| date | string | ISO8601 UTC timestamp | |
| 65 | +| status | string | "scraped", "tested", "published", or "verified" | |
| 66 | + |
| 67 | +## Requirements |
| 68 | + |
| 69 | +- **Method:** `GET` only |
| 70 | +- **Environment variables:** |
| 71 | + - `PROD_SERVER` — Solr server host |
| 72 | + - `SOLR_USER` — Solr basic auth username |
| 73 | + - `SOLR_PASS` — Solr basic auth password |
| 74 | +- **Dependencies:** `util/loadEnv.php` |
0 commit comments