Spatial Search using two separate fields for lat and long

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Spatial Search using two separate fields for lat and long

Tim Hedlund
Hi all,

I'm importing documents (rows in excel file) that includes latitude and longitude fields. I want to use those two separate fields for searching with a bounding box. Is this possible (not using deprecated LatLonType) or do I need to combine them into one single field when indexing? The reason I want to keep the fields as two separate ones is that I want to be able to export from solr back to exact same excel file structure, i.e. solr fields maps exactly to excel columns.

I'm using solr 7. Any thoughts or suggestions would be appreciated.

Regards
Tim

Reply | Threaded
Open this post in threaded view
|

Re: Spatial Search using two separate fields for lat and long

david.w.smiley@gmail.com
Hi,

I think your requirement of exporting back to CSV is fine but it's quite
normal for there to be some transformation steps on input and/or output...
and that such steps you mostly do yourself (not Solr).  That said, one
straight-forward solution is to have your spatial field be redundant with
the lat & lon separately.  Your spatial field could be stored=false, and
the separate fields would be stored but otherwise not be indexed or have
other characteristics that add weight.  The result is efficient; no
redundancies.

~ David Smiley
Apache Lucene/Solr Search Developer
http://www.linkedin.com/in/davidwsmiley


On Wed, Apr 3, 2019 at 1:54 AM Tim Hedlund <[hidden email]> wrote:

> Hi all,
>
> I'm importing documents (rows in excel file) that includes latitude and
> longitude fields. I want to use those two separate fields for searching
> with a bounding box. Is this possible (not using deprecated LatLonType) or
> do I need to combine them into one single field when indexing? The reason I
> want to keep the fields as two separate ones is that I want to be able to
> export from solr back to exact same excel file structure, i.e. solr fields
> maps exactly to excel columns.
>
> I'm using solr 7. Any thoughts or suggestions would be appreciated.
>
> Regards
> Tim
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Spatial Search using two separate fields for lat and long

Alexandre Rafalovitch
Specifically, the pre-processing can be done with
UpdateRequestProcessors:
https://lucene.apache.org/solr/guide/7_2/update-request-processors.html

In your case, you probably want to chain
*) CloneUpdate:
http://www.solr-start.com/javadoc/solr-lucene/org/apache/solr/update/processor/CloneFieldUpdateProcessorFactory.html
*) ConcatField:
http://www.solr-start.com/javadoc/solr-lucene/org/apache/solr/update/processor/ConcatFieldUpdateProcessorFactory.html

Note that ConcatField URP inherits FieldMutating URP, so you have some
flexibility on how you define the fields:
http://www.solr-start.com/javadoc/solr-lucene/org/apache/solr/update/processor/FieldMutatingUpdateProcessorFactory.html

Set the target field to index-only (not stored) and it will only be
used for search. The original fields can be set to be not-indexed, as
David already explained.

Regards,
   Alex.

On Sat, 13 Apr 2019 at 23:50, David Smiley <[hidden email]> wrote:

>
> Hi,
>
> I think your requirement of exporting back to CSV is fine but it's quite
> normal for there to be some transformation steps on input and/or output...
> and that such steps you mostly do yourself (not Solr).  That said, one
> straight-forward solution is to have your spatial field be redundant with
> the lat & lon separately.  Your spatial field could be stored=false, and
> the separate fields would be stored but otherwise not be indexed or have
> other characteristics that add weight.  The result is efficient; no
> redundancies.
>
> ~ David Smiley
> Apache Lucene/Solr Search Developer
> http://www.linkedin.com/in/davidwsmiley
>
>
> On Wed, Apr 3, 2019 at 1:54 AM Tim Hedlund <[hidden email]> wrote:
>
> > Hi all,
> >
> > I'm importing documents (rows in excel file) that includes latitude and
> > longitude fields. I want to use those two separate fields for searching
> > with a bounding box. Is this possible (not using deprecated LatLonType) or
> > do I need to combine them into one single field when indexing? The reason I
> > want to keep the fields as two separate ones is that I want to be able to
> > export from solr back to exact same excel file structure, i.e. solr fields
> > maps exactly to excel columns.
> >
> > I'm using solr 7. Any thoughts or suggestions would be appreciated.
> >
> > Regards
> > Tim
> >
> >