Search code examples
collectionssolrlucenespatial-query

Apache Solr - Lucene - Zip Code Radius Search


I have an existing collection of PERSON's records already loaded to my Solr Server. Each record has a field for a ZIPCODE. I know that Solr now supports spatial search with the geodist() function, the problem is that I do not have the lat and long for each person.

Can I add another collection to Solr mapping the ZipCodes to LATs and LONGs then JOIN them like you would with SQL? Is this even possible with Solr?


Solution

  • AFAIK, there isn't a way to translate Zipcode to Lat/Long in Solr.

    Most Geospatial queries (not restricted to Solr) use Latitude and Longitude to perform a radius search. So this isn't a Solr specific problem.

    I would recommend enriching the data that is imported into Solr using a GeoCoding API.

    You can update your existing index to have these fields populated for every document, but if possible I would prefer recreating the Solr Index with this data.

    I wouldn't include another collection for this purpose, JOIN isn't supported in Solr, as it isn't a relational data store.

    Edit: Solr does support JOIN, but in your case I would still not go for it, unless I have to.