I have a document in solr with Lat
and Lng
fields. I need to add a new field called store
containing data taken from both the Lat
and Lng
. I tried to use copyField
field but I got the error:
Field store is not multivalued and destination for multiple copyFields (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 content of two fields within the same destination field?
Maybe is it 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>
Taking your question without context:
Is it possible to copy the content of two fields within the same
destination field?"
The answer is yes, surely. The example schema does this with to copy multiple fields to a common "text" field (multiValued) to make searching by one field simpler.
But looking at more context, what you are actually trying to do is determine if Solr's schema.xml with copyField can take an input pair of fields (lat and lon in your case) and concatenate them with an intermediate comma to a particular field. The answer is no. You'll have to prepare the data this way when giving it to Solr, or use a DIH transformer if you are using the DIH (the DataImportHandler). I hesitate to suggest an alternative, but as a hack, you might try putting lat and lon into store_0_coordinate and store_1_coordinate (or maybe it's the other way around). But really, this isn't a recommended approach even if it might work.
You could try to set store
as multivalued
<field name="store" type="location" indexed="true" stored="true" multiValued="true" />
You can try something like that:
Two double in one location
if you can use DIH (Data Importer Handler). Hope thet will help!