Geolocation Search: Distance Facet Configuration
- 1 Search: Dashboard Configuration
- 2 Implementation Details
- 2.1 Indexing Geo Location
- 2.2 Searching within a Radius
- 2.2.1 Sorting Sets
- 2.2.2 Sample 1 – Get overall Geo Location Facet Values
- 2.2.3 Sample 2 – Including Facet Selection ‘Less than 100mi’
- 2.2.4 Sample 3 – Including Facet Selection ‘More than 1000mi’
- 2.2.5 Sample 4 – Including Facet Selection Returns no Results
- 2.2.6 Sample 5 – Including Facet Selection and Sorting by Nearest Location
- 2.2.7 Sample 6 – Including Facet Selection and Sorting by Farthest Location
- 3 Tracking for Reporting
- 4 Best Practices
Â
Hawksearch Versions: Hawksearch v4.0. Additional implementation changes might be needed to use this feature.
Note: Geolocation Search feature is already available for Hawksearch v4.0L clients. Please contact your Client Success Director for details and implementation.
Search: Dashboard Configuration
We have added a new range facet option - a Distance facet type which allows our customers to narrow down a list of results and sort them by distance within a chosen range. Your site visitors can now search by a zip code and get back list of relevant search results. This functionality will allow them to see the store location/products available in the physical location closest to them.
Fields
The first step to setting up Geolocation Search is to add a location field to your attribute.txt file and add a Location field under Workbench → Data Configuration → Fields. Make sure that this field is saved as a GeoPoint Value as shown below:
More information about setting up Fields can be found here.
Once the field is set up, the next step is adding a Distance facet.
Â
Facets
Distance facet falls under the Range facet type. A Location field needs to be passed to Hawksearch in feeds. Use the following configuration to set up a Geolocation Search facet:
You can choose preferred Distance Unit Type:
And Distance Calculation Type:
An Arc length is the distance between two points along a section of a curve
A Plane length is a flat surface with no thickness
Also, distance range facet values need to be set up:
More information about setting up Facets can be found here.
Setting Up Sorting Set for Distance Facet
Geolocation Search should be set up as a separate sorting set as it will only apply when a user is searching by zip code.
To define a Nearest option – please select sorting value with an option ‘Sort By’ equal to Asc
To define a Farthest option – please select sorting value with an option ‘Sort By’ equal to Desc
In a display rule a condition needs to be added to trigger this sorting set. We want to use this sorting set, only when a distance facet selection is made.
Display rule is defined as: Location is not {{empty}}
Sample setup:
For more information, please follow instructions on sorting sets refinement: Sorting/Pagination
Â
Implementation Details
Â
Note: Please review this article if you are not sure where to find your client guid.
Indexing Geo Location
Attribute file must contain latitude and longitude information for each item.
After fields configuration, the index needs to be rebuilt.
Put a ‘lat’ and ‘long’ values for the fields defined as geolocation:
v2/indexing/index-items:
Searching within a Radius
Sorting Sets
Example:
Â
Use ‘Origin’ to provide your current location. Let’s say you are currently in Europe
Sample 1 – Get overall Geo Location Facet Values
v2/search:
Go over the ‘Facet’ object in the response and look for the geo location facet, to see how many documents are indexed:
Sample 2 – Including Facet Selection ‘Less than 100mi’
Distance between Niece and Paris is less than 100mi, so the current facet selection will return the following results:
v2/search:
Response:
Facets object:
Results:
Sample 3 – Including Facet Selection ‘More than 1000mi’
Distance between Niece and US cities is more than 1000 mi, so the current facet selection will return results from both Europe and US:
v2/search:
Results:
Sample 4 – Including Facet Selection Returns no Results
There are no documents indexed with the 100 miles radius around Warsaw
v2/search:
Response:
Sample 5 – Including Facet Selection and Sorting by Nearest Location
In this example ‘Nearest’ is a default option of the sorting set. The results are sorted by the nearest.
v2/search:
Results:
Sample 6 – Including Facet Selection and Sorting by Farthest Location
Adding "SortBy":"Farthest" parameter to the request:
v2/search:
Results:
Tracking for Reporting
Even though the API request contains latitude and longitude, we have a mode where you can also pass a zip code in for tracking purposes. It is important to pass zip code in the object shown below if you are looking to see reporting around geolocation search. If zip code is not passed, no data will be tracked.
In order to track data for reporting, the following information needs to be passed to Hawksearch:
A new string property ZipCode has been added under ClientData object
To trigger a zip code search, ZipCode and Origin lat/lon must be passed
Â
Please note that zip codes that were searched for will appear in the Keyword column within Hawksearch Search reports.
Best Practices
As a best practice we recommend to use this facet for searches under 250 miles radius for performance reasons. If you are looking to pull in results for a larger radius or see all possible results, a different approach may need to be chosen. Please reach out to our Support or Client Success Directors teams should you have questions.