I had a similar need in an old solr project. I was able to handle it with this configuration in solrconfig.xml:
<updateRequestProcessorChain name="defaultUpdateRequestProcessorChain" default="true"> <processor class="solr.CloneFieldUpdateProcessorFactory"> <str name="source">lastModified</str> <str name="dest">realLastModified</str> </processor> <processor class="solr.FirstFieldValueUpdateProcessorFactory"> <str name="fieldName">realLastModified</str> </processor> <processor class="solr.LogUpdateProcessorFactory" /> <processor class="solr.RunUpdateProcessorFactory" /> </updateRequestProcessorChain> The logic is basically: Copy the default value (lastModified here) into the target field (realLastModified). If the target field has a value from earlier, then the FirstFieldValueUpdateProcessorFactory will remove the default value and the specified value is used. If no value was specified, then the default value is the only value there, and it remains there. Note that this configuration comes from an old solr project, so there might be a more modern way to configure this. But the essence of this solution should still work fine. /Jimi ufuk yılmaz wrote: > > When I have a copyfield directive like, > > <field name=”a” multiValued=”false”... > <field name=”b” multiValued=”false”... > <copyField source=”a” dest=”b”... > > And I send a document containing field named “b”, Solr tries to write 2 > values into “b” field (one from the incoming doc and one from the copyfield) > and gives error because “b” is not a multi valued field. > > Is it possible to activate copyField directive only when dest field is absent > from the incoming document? > Svenskt Näringsliv är företagsamhetens röst i Sverige. Vi samverkar med 50 arbetsgivar- och branschorganisationer och är den gemensamma rösten för 60 000 företag med nästan 2 miljoner medarbetare. Vår uppgift är att tala för alla företag och branscher, även de som ännu inte finns men som kan uppstå om förutsättningarna är de rätta. Ett bättre företagsklimat för ett bättre Sverige. Det är vårt uppdrag. Svenskt Näringsliv behandlar dina personuppgifter i enlighet med GDPR. Här kan du läsa mer om vår behandling och dina rättigheter, Integritetspolicy<https://www.svensktnaringsliv.se/dataskydd/integritet-och-behandling-av-personuppgifter_697219.html?utm_source=sn-email&utm_medium=email>