I've defined following field in my schema to store latitude and longitude-

<field name="loc_coords" type="location" uninvertible="true" indexed="true"
stored="true" sortMissingLast="true" multiValued="true"/>

and "location" is of following field type
<fieldType name="location" class="solr.LatLonPointSpatialField"
docValues="true"/>

I'm storing multiple latitude and longitude pairs in loc_coords field and
using a "geofilt" filter successfully able to retrieve the documents close
to a given point. I'm looking for your advice on how I can store the
location names, corresponding to latitude/longitude pairs and return them
in search result e.g. if "loc_coords" has following lat/long coordinates
for "London" and "New York"

["51.5072,0.1276", "40.7128,74.0060"]

In my search query when I'm looking for documents *near *to "New York" then
the above document will be returned  and in the search result I also want
to return the location name "New York".

I'm considering following two approaches to store location names and return
them in search result-

1. Store location names in a string array field ( call it location_names)
in the same order as lng/lat pair in location_coords field and somehow find
the index of matching lng/lat pair and use the index on location_names
field to retrieve the location name. This is just logical thinking. I'm not
sure how I can achieve it in Solr.

2. Store the data as GeoJson in solr because GeoJson allows to store extra
information along with coordinates as mentioned here- https://geojson.org/.
But I'm not sure how I'm going to get the location name of matching
coording in the search result.

Thank you for the help.

GS

Reply via email to