Sort Search Job Title results with sortBy
Sort Search Job Title results with sortBy
window.hapi.service.product.getJobTitles(text, sortBy?) now accepts an
optional second argument to control the order of the results returned by the
Search Job Title endpoint.
Sort options
sortBy accepts a value from the new JobTitleSortBy enum (exported from
@vonq/hapi-elements-types):
| Value | Constant | Order |
|---|---|---|
relevance | JobTitleSortBy.relevance | Search relevance (default) |
frequency.desc | JobTitleSortBy.frequencyHighToLow | Most frequently used titles first |
frequency.asc | JobTitleSortBy.frequencyLowToHigh | Least frequently used titles first |
name.asc | JobTitleSortBy.nameAsc | Localized name, A to Z |
name.desc | JobTitleSortBy.nameDesc | Localized name, Z to A |
import { JobTitleSortBy } from "@vonq/hapi-elements-types"
// Alphabetical by localized name
await window.hapi.service.product.getJobTitles(
"developer",
JobTitleSortBy.nameAsc,
)The valid values are also available at runtime via
window.hapi.utils.product.jobTitleSortByKeys.
Job-title filter widget
A Sort by control for the job-title filter widget is being rolled out and is
not yet enabled by default, so the widget behaves exactly as before for now.
When enabled, it appears next to the job title field so it's clear the
control affects that search: end users can choose the order of the suggested
titles (Relevance — the default — Name A–Z / Z–A, or Most / Least used), the
chosen order is applied to the autocomplete suggestions, the selection is
remembered while navigating between steps, and the two fields stack on narrow
screens. You don't need to wait for the in-widget control — the
getJobTitles(text, sortBy) SDK call shown above applies a sort order today.
Name sorting and language
name.asc and name.desc sort by the title name in the language resolved from
the current locale (the language Elements already sends with each request),
falling back to the default language. You don't need to do anything extra — set
the locale as usual and the name order follows it.
Backwards compatibility
sortByis optional. CallinggetJobTitles(text)with no second argument behaves exactly as before (relevance-ranked results).- The in-widget Sort by control is not enabled by default, so the job-title field is unchanged.
- No SDK function, getter, setter, property, or event was removed or renamed.
- No translation keys were removed.
I18n
The following i18n translations have been added (used by the Sort by dropdown in the job-title filter widget):
| Key | "en" value | "de" value | "nl" value | "fr" value | "es" value | "it" value |
|---|---|---|---|---|---|---|
| products.filters.job-title-sort-by-label | Sort by | Sortieren nach | Sorteren op | Trier par | Ordenar por | Ordina per |
| products.filters.job-title-sort-by-description | Choose the order of the suggested job titles | Wählen Sie die Reihenfolge der vorgeschlagenen Jobtitel | Kies de volgorde van de voorgestelde functietitels | Choisissez l'ordre des intitulés de poste suggérés | Elige el orden de los puestos sugeridos | Scegli l'ordine dei titoli di lavoro suggeriti |
| products.job-title-sort-by.relevance | Relevance | Relevanz | Relevantie | Pertinence | Relevancia | Rilevanza |
| products.job-title-sort-by.name-asc | Name (A–Z) | Name (A–Z) | Naam (A–Z) | Nom (A–Z) | Nombre (A–Z) | Nome (A–Z) |
| products.job-title-sort-by.name-desc | Name (Z–A) | Name (Z–A) | Naam (Z–A) | Nom (Z–A) | Nombre (Z–A) | Nome (Z–A) |
| products.job-title-sort-by.frequency-high-to-low | Most used | Am häufigsten verwendet | Meest gebruikt | Les plus utilisés | Más utilizados | Più utilizzati |
| products.job-title-sort-by.frequency-low-to-high | Least used | Am wenigsten verwendet | Minst gebruikt | Les moins utilisés | Menos utilizados | Meno utilizzati |