Avatria recommends using Algolia’s Geospatial capabilities as the mechanism for implementing the query specific product rankings (i.e. sorting) provided by Avatria Convert.
The first step will be to introduce the Avatria Convert ranking information into the Algolia product index by encoding the ranking information as spatial coordinates on the product records. The spatial coordinates should be added within the standard Algolia “_geoloc” field.
Note: Contact the Avatria team for assistance in generating geospatial data for your rankings.
After the product records are updated, they should resemble the following format.
Example for ProductSKU/Offer 4512:
{
"objectID": "5702341",
[. . . other fields . . .]
"_geoloc": [
{ "lat": 47.279430, "lng": 5.106450 },
{ "lat": 47.293228, "lng": 5.004570 },
{ "lat": 47.316669, "lng": 5.016670 }
]
}
Note that each product could have zero or more spatial points associated with it.
Options for Integrating Ranking Data:
- Avatria can provide a file in the desired format (TSV/CSV/JSON) which contains product specific ranking information represented as spatial coordinates. This could then be imported by your team. Some examples:
- Importing ranking data into Content/Catalog Management systems as new attributes of the product, and then updating the product indexing process to include this data as part of the product record in the search index.
- Using the Algolia Dashboard or API to directly load these updates into the Algolia search index.
- Alternatively, Avatria Convert can also “push” the ranking information directly into Algolia using the Algolia API via a direct integration. The Avatria team would just need to be provided an Algolia API Key to allow for connecting & updating index information, as well as some basic information from your team to allow for configuring and testing.
Expose Geospatial Sort Query Parameter
Given the approach to achieve the rankings via Algolia’s Geospatial capabilities, exposing some of the Geospatial capabilities of Algolia through an URL query parameter should meet our needs.
We recommend a general-purpose approach which allows for sorting results by distance from a point, and which allows the point value to be fully configurable on the frontend.
Query Parameter |
Geospatial sort Expression |
Comments |
<your query parameter> |
geo[{lat},{lng}] Examples: geo[89.92050,170.0000-] geo[-89.00000,-179.00000] geo[0.0,0.0]
|
New sort option which would allow for sorting results according to the provided lat/lng coordinates. When this sort parameter is present, the system should query Algolia for results using the aroundLatLng with the given lat/lng values. Attributes: - lat: float value representing the point’s latitude - lng: float value representing the point’s longitude See aroundLatLng query parameter documentation for more information. The aroundPrecision parameter’s default value of 1 will be sufficient for our needs and does not need to be explicitly specified, assuming the default value has not been customized. |
The point coordinates passed to the query parameter will be the optimal coordinate values to ensure the results are sorted and presented to the user in the order recommended by the Avatria Convert ranking models.
It is important to understand that it is the combination of the query specific geo coordinates (passed at runtime) AND the product specific geo coordinates (stored at index time), which are required for this approach to work.