Location
Site Search > Configurations > Advanced Configurations > Location
Overview
Location-Based Search enhances the SearchStax Site Search experience by using location data to return the most geographically relevant results, sorted, filtered, or boosted by proximity to the search user.
Premium and Advanced Accounts Only
The SearchStax Site Search Location-based search features are available to Premium and Advanced accounts, as noted on our Pricing page.
Location Inputs
Location matching calculates the distance between a search user and various objects represented in the Solr index. To make this calculation, it requires two kinds of inputs:
- Users must provide their zip code or city name when framing a query to establish their location. A field for these values is provided on the Hosted Search Experience.
- The index records must contain decimal latitude and longitude coordinates for each locatable object in a form similar to
"location_p": "34.0629,-118.3581"
. The field must be a solr.LatLonPointSpatialField. You can achieve this in Site Search by appending the _p dynamic field type suffix to the field name before uploading the data. For Drupal, use the locs_ prefix.
Location Search Features
Location-based logic can be applied in these ways:
- Distance Results: Calculate and display a Distance value for each item in the search results.
- Distance Filtering: Display only the results located within a defined radius (for instance, within 10 miles).
- Distance-Based Boosting: Boost an object’s match score based on proximity to the user.
- Distance-Based Sorting: Sort best-matching results by distance to the user (nearest results first).
Distance can be configured in miles or in kilometers.
Enable Location Features
Navigate to Site Search > Configurations > Advanced Configurations > Location.

To enable location-based search features:
- Engage the Enable Location toggle.
- Select the Location Field (the field that contains the latitude/longitude data). If you don’t see the field in the droplist, click the Reload Schema button.
- Indicate Distance Units (miles or kilometers).
- Optionally, enable a Location Results Field. This option adds lat/long values to the search results to support custom map-based UI features in your search page.
It also automatically maps this field to an invisible Location field on the Hosted Search Experience results card.The invisible field hides the lat/long data from casual viewers while leaving it programmatically available to front-end developers. To make the lat/long values visible, remove the Location mapping from the field!
Remember to Publish your changes before you leave the page.
Distance Results Field
Site Search can optionally include a Distance field in the search results, showing the distance (in miles or kilometers) between the search user’s location and the matching item:

This field is automatically named after the lat/long field with an added _distance suffix, as in location_p_distance
. Setting the toggle automatically adds this field to the Results Fields.


The value appears among the “unmapped” fields at the bottom of the Hosted Search Experience result item:

Note that the field will not appear until the user enters a location (zip code or city name) on the search page.
Results without Lat/Long Data
Result items that lack position data return a calculated distance of “Infinity”. The Hosted Search Experience and the Preview screen suppress this result, showing no distance value.
Distance Filtering
The Distance Filter feature excludes matching documents that are more than a specific distance from the search user. When this feature is enabled, the Hosted Search Experience offers a dropdown list of search radii to select from.

To enable and configure this feature from the Location screen:

- Engage the Enable Distance Filter toggle.
- Enter a Distance Filter Label. This label appears only in the search-results metadata, for the convenience of your search page developers:
- The remainder of the controls manage the dropdown menu of search radii. “Any Distance” must always be present, but you can add or remove other options to suit your use case.
- To add an option, enter the desired distance and click the (+) button.
- To remove an option, click the (x) button beside it.
- Use the radio buttons to choose one option as the default.
Remember to Publish the changes.
Distance-Based Boosting
The Distance-Based Boost feature is a ranking multiplier on the partial score contributed by the Distance field. This is an inverse multiplier, meaning that small distances are boosted more than large ones.
Enable the feature using the Enable Distance-Based Boost toggle on the Location screen:

When enabled, a boost control for the Distance field appears automatically on the Ranking screen:

If this boost is in the Main Profile (the default), the Ranking Boost multiplier is automatically set to 1. If not, the Boost multiplier is set to 0. You can adjust the boost as you wish.
Remember to Publish your changes.
Distance-Based Sorting
Distance-Based Sorting is the simplest of the Location-Based Search features. It sorts search results according to the inverse of the Distance field, so nearby results are at the top of the list.
Use the Enable Distance-Based Sorting toggle to activate this feature.

When enabled, this feature adds a geodist()
sorting function to the Sorting screen and labels it “Distance.” This becomes one of the sorting options on the Hosted Search Experience.

If you’d like to sort in the opposite direction, change Ascending to Descending.
Questions?
Do not hesitate to contact the SearchStax Support Desk.