Building a Boolean Job Search Query Generator in JavaScript
Job boards and search engines reward precise queries, but most people type something vague like "energy jobs Oman" and scroll through noise. Recruiters and sourcers fix this with Boolean strings. In this post we'll build a small JavaScript utility that generates them automatically from a few structured inputs.
We'll use energy contract roles in Oman as the running example, but the pattern works for any sector.
The query model
A focused job search has four parts:
Specialization + Sector + Location + Employment type
Each part has synonyms. An "Electrical Engineer" might be listed as "E&I Engineer", and "contract" might appear as "contractor" or "fixed-term". A good generator expands each part into an OR group and joins the groups with AND.
The synonym map javascript const SYNONYMS = { employment: { contract: ["contract", "contractor", "fixed-term", "project-based"], permanent: ["permanent", "full-time", "staff"], }, sector: { energy: ["energy", "power", "utilities"], oilgas: ["oil and gas", "O&G", "upstream", "downstream"], renewables: ["renewable", "solar", "wind"], nuclear: ["nuclear", "NPP"], }, role: { electrical: ["Electrical Engineer", "E&I Engineer", "Electrical Supervisor"], hse: ["HSE Engineer", "HSE Officer", "Safety Engineer"], project: ["Project Engineer", "Project Manager", "Site Engineer"], commissioning: ["Commissioning Engineer", "Start-up Engineer"], }, }; Building the query javascript const quote = (term) => (term.includes(" ") ? "${term}" : term);
const orGroup = (terms) => terms.length === 1 ? quote(terms[0]) : (${terms.map(quote).join(" OR ")});
function buildQuery({ role, sector, location, employment }) { const parts = [ SYNONYMS.role[role], SYNONYMS.sector[sector], [location], SYNONYMS.employment[employment], ].filter(Boolean);
return parts.map(orGroup).join(" AND "); }
console.log( buildQuery({ role: "electrical", sector: "energy", location: "Oman", employment: "contract", }) );
Output:
("Electrical Engineer" OR "E&I Engineer" OR "Electrical Supervisor") AND (energy OR power OR utilities) AND Oman AND (contract OR contractor OR fixed-term OR project-based) Generating variations in bulk
A single query misses listings that use different wording, so generate every role and sector combination:
javascript function buildAll({ roles, sectors, location, employment }) { return roles.flatMap((role) => sectors.map((sector) => ({ role, sector, query: buildQuery({ role, sector, location, employment }), })) ); }
const queries = buildAll({ roles: ["electrical", "hse", "project"], sectors: ["energy", "oilgas", "renewables"], location: "Oman", employment: "contract", });
console.table(queries);
That produces nine focused queries from one config object.
Platform caveats Google supports OR, quotes, and parentheses. AND is implicit, but writing it explicitly does no harm. LinkedIn supports full Boolean in keyword search. The operators must be uppercase. Most job boards support only partial Boolean. If results look strange, drop the parentheses and run the groups separately. Keep queries under about 32 terms. Google silently ignores anything past that. Extending it
A few ideas if you want to take it further:
Add a NOT group to exclude noise such as -intern -trainee Build URL-encoded search links for specific sites with encodeURIComponent Load the synonym map from JSON so non-developers can edit it Wrap it in a small form UI so candidates can generate their own strings
The takeaway: structured inputs plus synonym expansion beat hand-typed searches every time. The same pattern powers sourcing tools and job-matching filters. At avua we apply similar structured matching across energy and technical roles, and you can see how contract listings are organized on avua's contract jobs page.
Comments
Join the discussionNo comments yet. Be the first to comment.