Step 2: Use Frontend Logic (Automatic)
- Set up the location entities and link them to the professional entity. For a refresher, check out the
Linked Entities
training.
In the configuration for the professionals vertical, make the geolocation of those linked facilities searchable. For a refresher, check out the trainings on making entity relationships searchable and enabling geolocation filters across entity relationships . This will return this professional entity for searches that are relevant to all their address locations. Note you can only add this in the JSON editor, which will look something like:
{ "verticals": { "professionals": { "searchableFields": { "c_practicingLocations.builtin.location": { "nlpFilter": true } } } } }
Populate display fields with at least one projected coordinate field. We recommend using
yextDisplayCoordinate
because that’s the primary coordinate for an entity. For a refresher on display fields, check out the searchable and display fields unit.Run a search using Test Search to view the API response. Notice that within the list of linked locations for each professional entity, the API response will indicate which linked location is closest to the user (by setting
nearestToUser
totrue
) and which is closest to any searched location filter (by settingnearestToFilter
totrue
).nearestToFilter
will only be populated if there’s a matched location filter for the search, such as “doctors in Arlington” matching on Arlington.Now that the API response is returning
nearestToUser
andnearestToFilter
, you can use these properties to implement frontend logic to choose which entities to display. Every setup will look different, but essentially you’ll use a logic statement to show the result card of the entity withnearestToUser
ornearestToFilter
set totrue
and not show the result cards of the entities that don’t have this property. This will allow you to surface only one result card per professional.
Note: Since you are using frontend logic to choose which entities to display, the frontend may show different results than Search Logs, API responses, and Analytics. This could potentially cause issues for dynamic reranking, sorting logic, or troubleshooting the experience. Keep this in mind while debugging.