Problem statement
Build a REST API for searching a job board with any mix of optional filters, returned one page at a time.
Requirements
JobPostingRepository
Extend the repository so that, alongside the CRUD operations it already has, one call can:
- Take the dynamically composed filter condition built by JobPostingSpecifications, rather than a fixed query
- Apply paging and sorting to that same call
- Report the total number of postings the condition matches, not only the ones on the returned page
JobPostingSpecifications
Fill in buildSpecification so it combines whichever filter values are present into one condition the repository can execute. It receives title and location as text, salaryMin as a number, and the requested tags as a list, and any of them may be absent.
- title keeps only postings whose title contains it, ignoring case, so a search for java also finds a posting titled Senior Java Engineer
- location keeps only postings whose location equals it, ignoring case; a value that merely starts a stored location matches nothing
- salaryMin keeps only postings whose salary is at least that value; a posting paying exactly salaryMin is kept
- The tag list keeps only postings that carry every listed tag, so a posting carrying just one of two requested tags is excluded; tags are compared exactly, and a requested tag differing only in case matches nothing
- A value that is absent, or blank for title and location, contributes no restriction
- The supplied filters compose: a posting is returned only when it satisfies all of them at once, and when nothing is supplied the condition matches every posting
JobController
Implement the single REST endpoint, reachable at exactly the verb and path listed below.
GET /jobs
- All six query parameters are optional: title, location, salaryMin, tags, page, and size
- Return 200 OK with a JSON object holding exactly five keys: content, page, size, totalElements, and totalPages
- content is the requested page of matching postings, each carrying exactly id, title, location, salary, and tags, where tags lists the posting's tags in the order they are stored
- A request without any filter returns every stored posting
- tags holds one tag or several separated by commas, and is parsed into the list handed to the filter condition; a blank tags, empty or whitespace-only, yields no tags and so applies no restriction
- Matching postings are ordered by salary descending, and postings with equal salary by id ascending; the order carries across pages
- page reports the zero-based page number that was served, size the page size that was applied, totalElements the number of postings that match the supplied filters, not the number stored, and totalPages the number of pages that filtered result spans at that size; for example, 12 matching postings at size 5 span 3 pages
- When page is omitted it defaults to 0, the first page
- When size is omitted it defaults to 10
- Requested sizes from 1 through 50 are applied exactly as given
- Any requested size above 50 is clamped to 50: at most 50 postings are returned and the envelope reports a size of 50
- A page past the end of the result returns 200 OK with an empty content array while totalElements and totalPages stay correct
- When no posting matches the filters, and likewise when none is stored, return 200 OK with an empty content array, a totalElements of 0, and a totalPages of 0
- If page is negative, return 400 Bad Request with error message: "Page must be at least 0"; a page of exactly 0 is valid
- If size is less than 1, return 400 Bad Request with error message: "Size must be at least 1"; a size of exactly 1 is valid
- If page, size, or salaryMin is not a number, return 400 Bad Request
Sample Requests & Responses
Expand to view details on sample requests and responses.
GET /jobs
Response (200 OK):
{
"content": [
{
"id": 12,
"title": "Engineering Manager",
"location": "Berlin",
"salary": 110000,
"tags": [
"management",
"backend"
]
},
{
"id": 9,
"title": "Machine Learning Engineer",
"location": "Berlin",
"salary": 105000,
"tags": [
"python",
"ml"
]
},
{
"id": 1,
"title": "Senior Java Engineer",
"location": "Berlin",
"salary": 95000,
"tags": [
"java",
"backend"
]
},
{
"id": 7,
"title": "DevOps Engineer",
"location": "Remote",
"salary": 91000,
"tags": [
"devops",
"remote"
]
},
{
"id": 6,
"title": "Product Manager",
"location": "Remote",
"salary": 88000,
"tags": [
"product",
"remote"
]
},
{
"id": 4,
"title": "Data Engineer",
"location": "Munich",
"salary": 83000,
"tags": [
"python",
"data"
]
},
{
"id": 11,
"title": "Backend Developer",
"location": "Munich",
"salary": 77000,
"tags": [
"java",
"backend"
]
},
{
"id": 3,
"title": "Frontend Engineer",
"location": "Berlin",
"salary": 72000,
"tags": [
"javascript",
"frontend"
]
},
{
"id": 2,
"title": "Java Developer",
"location": "Remote",
"salary": 68000,
"tags": [
"java",
"remote"
]
},
{
"id": 8,
"title": "QA Analyst",
"location": "Munich",
"salary": 54000,
"tags": [
"testing",
"qa"
]
}
],
"page": 0,
"size": 10,
"totalElements": 12,
"totalPages": 2
}
GET /jobs?title=java
Response (200 OK):
{
"content": [
{
"id": 1,
"title": "Senior Java Engineer",
"location": "Berlin",
"salary": 95000,
"tags": [
"java",
"backend"
]
},
{
"id": 2,
"title": "Java Developer",
"location": "Remote",
"salary": 68000,
"tags": [
"java",
"remote"
]
},
{
"id": 5,
"title": "Junior Java Developer",
"location": "Berlin",
"salary": 46000,
"tags": [
"java",
"junior"
]
}
],
"page": 0,
"size": 10,
"totalElements": 3,
"totalPages": 1
}
GET /jobs?location=berlin&salaryMin=95000
Response (200 OK):
{
"content": [
{
"id": 12,
"title": "Engineering Manager",
"location": "Berlin",
"salary": 110000,
"tags": [
"management",
"backend"
]
},
{
"id": 9,
"title": "Machine Learning Engineer",
"location": "Berlin",
"salary": 105000,
"tags": [
"python",
"ml"
]
},
{
"id": 1,
"title": "Senior Java Engineer",
"location": "Berlin",
"salary": 95000,
"tags": [
"java",
"backend"
]
}
],
"page": 0,
"size": 10,
"totalElements": 3,
"totalPages": 1
}
GET /jobs?tags=java,backend
Response (200 OK):
{
"content": [
{
"id": 1,
"title": "Senior Java Engineer",
"location": "Berlin",
"salary": 95000,
"tags": [
"java",
"backend"
]
},
{
"id": 11,
"title": "Backend Developer",
"location": "Munich",
"salary": 77000,
"tags": [
"java",
"backend"
]
}
],
"page": 0,
"size": 10,
"totalElements": 2,
"totalPages": 1
}
GET /jobs?tags=remote&size=2&page=1
Response (200 OK):
{
"content": [
{
"id": 2,
"title": "Java Developer",
"location": "Remote",
"salary": 68000,
"tags": [
"java",
"remote"
]
},
{
"id": 10,
"title": "Technical Writer",
"location": "Remote",
"salary": 52000,
"tags": [
"docs",
"remote"
]
}
],
"page": 1,
"size": 2,
"totalElements": 4,
"totalPages": 2
}
GET /jobs?title=cobol
Response (200 OK):
{
"content": [],
"page": 0,
"size": 10,
"totalElements": 0,
"totalPages": 0
}
GET /jobs?page=-1
Response (400 Bad Request):
{
"error": "Page must be at least 0",
"timestamp": "2026-08-05T21:28:50.615226",
"path": "/jobs"
}
GET /jobs?salaryMin=abc
Response (400 Bad Request):
{
"timestamp": "2026-08-05T15:43:50.747+00:00",
"status": 400,
"error": "Bad Request",
"path": "/jobs"
}
