I create one demo instantsearch js with typesense.
Issue is when i search city the result come all result not filtering with _geoloc and polygon.
I use _geoloc field to store lat long with float array in typesense.
{"name": "_geoloc", "type": "float[]" , "facet": true },
And _geoloc pass geoLocationField parameter in Typesense instantSearch adapter.
const polygon = [
42.01,-124.31,
48.835509470063045,-124.40453125000005,
45.01082951668149,-65.95726562500005,
31.247243545293433,-81.06578125000004,
25.924152577235226,-97.68234374999997,
32.300311895879545,-117.54828125
];
const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
server: {
apiKey: "xyz",
nodes: [{
host: "localhost",
port: "8108",
protocol: "http",
}, ],
cacheSearchResultsForSeconds: 2 * 60,
},
insidePolygon: [polygon],
geoLocationField: "_geoloc",
additionalSearchParameters: {
queryBy: "name",
},
});
Thank you for helping @ErJab
After some research, I got a new solution and it's working perfectly.
Typesense adapter updated their code for the polygon search.
now we can able to search inside a polygon.
const polygon = [
42.01,-124.31,
48.835509470063045,-124.40453125000005,
45.01082951668149,-65.95726562500005,
31.247243545293433,-81.06578125000004,
25.924152577235226,-97.68234374999997,
32.300311895879545,-117.54828125
];
const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
server: {
apiKey: "xyz",
nodes: [{
host: "localhost",
port: "8108",
protocol: "http",
}, ],
cacheSearchResultsForSeconds: 2 * 60,
},
geoLocationField: "_geoloc",
additionalSearchParameters: {
queryBy: "name",
},
});
const searchClient = typesenseInstantsearchAdapter.searchClient;
const search = instantsearch({
searchClient,
indexName: "airports",
});
search.addWidgets([
searchBox({
container: '#searchbox',
placeholder: 'Search for products',
}),
configure({
insidePolygon : polygon,
}),
]);