Geolocalized results with multiple locations per item
I would like to get results that are geolocalized. I have found this documentation, but my unique case is that each item has a list locations and I want to return the item ands its location(s) that are within the specified radius.
I am wondering about the best practice for going about this. I think I could make my own function that traverses each item's list of lat/longs and compares that with the reference point, while adding the in range locations to a temporary field and also setting a temporary field for the distance value for the closet location so that I can sort my results.
Any thoughts on this would be gerat
Is this question related to your question about returning array from a computed index field? https://answers.coveo.com/questions/5342/returning-array-from-a-computed-field
To work, the
dist query function needs the lat and long to be in floating point fields inside the CES index. As I explained in the other question, the only way to store multiple values in a single CES field is with the string field type and the multi-value facet option.
I see 2 options for your use case:
- Index the various locations in separate fields. If you know an item won't have more than 5 locations, you can create 5 pair of computed index fields for your locations lat and long fields.
- Index each Sitecore item multiple times with a different location in each. You can do this by creating a processor for the
<coveoPostItemProcessingPipeline>. There's documentation and examples in those 2 links: link1, link2. In the processor, you wold duplicate the item as many time as the number of locations and keep only one location per item. The unique ID of each item must be different, thus I suggest to include the location information in the unique ID strings. You can then merge the search results together in the UI with various methods.