I've been working on implementing geo search with Algolia for a web project. Here's the code snippet I have so far:
var searchClient = algoliasearch(Algol_APP_ID, Algol_API_KEY);
var itemIndex = searchClient.initIndex('item');
function searchItems(keyword, lat, lng) {
var prom;
var searchObj = {
query: keyword,
aroundRadius: 200
};
searchObj.aroundLatLngViaIP = true;
return itemIndex.search(searchObj)
.then(function (content) {
console.log(content);
return content;
})
}
When I comment out
searchObj.aroundLatLngViaIP = true;
, I'm able to retrieve items. However, when this line is included, I no longer get any results from Algolia. It seems like the issue may be related to the data structure, as I don't have the _geoloc
parameter mentioned in tutorials. I couldn't find any documentation stating that the lat
and lng
parameters must be encapsulated within this parameter. If anyone can confirm this as the problem, I'm wondering if there's a way to alias a parameter in Algolia to match this format instead of having to rewrite all the data in my database.