Switch off _geoloc in main index search; SortBy _geoloc from replica index

sorting
replicas
geosearch

#1

How do I selectively switch on/off ordering by _geoloc on an index?

I need to provide custom sorting of results from text (e.g. search bar) or filtered search (e.g. products from a collection) for multiple user-selected attributes like popularity (default), geo-distance (asc), price (asc) and price (desc). Now the question being how do I set sortBy _geoloc on a replica index, and switch it off on the main index with custom ranking popularity attribute.

I think one way is to use replica index for my default sortBy settings (i.e. popularity) and make _geoloc ordering as primary index but user selected search trigger. This feels counter-intuitive to me. Also _geoloc ordering of results will have to be shut down on this replica instead now.

Furthermore, I assume I must be simply missing things from the docs. Please guide me. Thanks all :slight_smile:


#2

Hi there,

Thanks for contacting Algolia!

To best help you, we would need to see the issue live for example with a live URL or if you replicate it in a codesandbox, and in each case with steps to replicate the issue (e.g., “You type in X, and then see empty boxes”). You can start with this codesandbox boilerplate if helpful:

Please let us know how it goes. We look forward to your reply!

Best regards,


#3

Hello @jason.sooter Thanks for your reply. There is no issue with code or so, that I could reproduce. The query is about design, how do I set up algolia indexes to not use geo ordering when I don’t need it even when _geoloc attribute is present for all the datapoints.

EDIT: I think I could just delete geosearch from all indexes but one. Would that be bad?

UPDATE: I have used sorting by attribute in replica indexes without removing geo ordering, since I assume that records in those indexes will first be sorted by the specified order, and then geo ordering will be used to resolve rank conflicts which should be okay. Now I can see why this has been a stupid question.