How to copy 2 data fields into one field on Solr

I have a document in solr with Lat and Lng . I need to add a new field called store containing data taken from Lat and Lng . I tried using the copyField field, but I got an error:

Field storage is not ambiguous, but assignment for multiple copies of copies (2)

Here is my configuration:

 <fields> <field name="lat" type="sdouble" indexed="true" stored="true" required="true" multiValued="false" /> <field name="lng" type="sdouble" indexed="true" stored="true" required="true" multiValued="false" /> <field name="store" type="text" indexed="true" stored="true"/> </fields> <copyField source="lat" dest="store"/> <copyField source="lng" dest="store"/> 

Is it possible to copy the contents of two fields in the same destination field?

+7
source share
4 answers

Taking your question out of context:

Can I copy the contents of two fields in the same destination field? "

The answer is yes, of course. In an exemplary scheme, this is done to copy several fields into a common "multi" field (multiValued), to simplify the search for one field.

But looking at more context, what you are actually trying to do is determine if Solr schema.xml with copyField can take an input pair of fields (lat and lon in your case) and combine them with an intermediate comma on a specific field. The answer is no. You will need to prepare the data this way when you pass it to Solr, or use a DIH transformer if you use DIH (DataImportHandler). I hesitate to offer an alternative, but as a hack, you can try putting lat and lon in store_0_coordinate and store_1_coordinate (or maybe vice versa). But this is actually not a recommended approach, even if it can work.

+6
source

It may be outdated, but you can use "updateRequestProcessorChain"

 <updateRequestProcessorChain name="composite-position"> <processor class="solr.CloneFieldUpdateProcessorFactory"> <str name="source">lat</str> <str name="source">lng</str> <str name="dest">store</str> </processor> <processor class="solr.ConcatFieldUpdateProcessorFactory"> <str name="fieldName">store</str> <str name="delimiter">;</str> </processor> <processor class="solr.LogUpdateProcessorFactory" /> <processor class="solr.RunUpdateProcessorFactory" /> </updateRequestProcessorChain> 
+4
source

You can try installing store as multivalued

 <field name="store" type="location" indexed="true" stored="true" multiValued="true" /> 
+2
source

You can try something like this:

Two doubles in one place

if you can use DIH (Data Importer Handler). Hope this helps!

0
source

All Articles