Ok, thank very much. When I try a second atomic udpate is when I got the exception you mentioned "multiple values encountered for non multiValued copy field". First time there is not exception but the non-multivalued field get indexed with 2 values.
Cheers. ________________________________________ From: Alessandro Benedetti [benedetti.ale...@gmail.com] Sent: Wednesday, July 15, 2015 2:28 PM To: solr-user@lucene.apache.org Subject: Re: Does update field feature work in a schema with dynamic fields? Going through the code in the RunUpdateRequestProcessor we call at one point : … Document luceneDocument = cmd.getLuceneDocument(); // SolrCore.verbose("updateDocument",updateTerm,luceneDocument,writer); writer.updateDocument(updateTerm, luceneDocument); .. Inside that method we call : public Document getLuceneDocument() { return DocumentBuilder.toDocument(getSolrInputDocument(), req.getSchema()); } Then exploring the toDocument we find what we need : org/apache/solr/update/DocumentBuilder.java:114 And looking into there we realise it is a bug : … if (!destinationField.multiValued() && destHasValues) { throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "ERROR: "+getID(doc, schema)+"multiple values encountered for non multiValued copy field " + destinationField.getName() + ": " + v); } ... Because the check is actually checking in already used fields, not expecting the copy field to be already valorised. Hence the exception coming. I will create an issue for that and provide a patch as soon as I have time ( or anyone can provide the patch). Cheers 2015-07-15 12:27 GMT+01:00 Alessandro Benedetti <benedetti.ale...@gmail.com> : > Ohhh! > I didn't read it completely, so i missed the copy field. > Ok now. > This is the explanation : > Copy fields are added at indexing time, when the document arrived to the > RunUpdateRequest processor. > If i remember well at this point , before we start the indexing the > content of source field is added to the copy field as a value. > > The first time you indexed your document , the first copy was added. > > What you didn't know is the fact that actually atomic update works in this > way : > > 1) I get the current Doc from the index ( the stored fields), > 2) I do the update, and > 3) then I send the document to the indexing processing chain *again*. > So the value is copied a second time. > > This will produce the duplicate value. > I can go in deep, but I think this is the cause. > > Cheers > > > 2015-07-15 12:10 GMT+01:00 Martínez López, Alfonso <almlo...@indra.es>: > >> Hi, thanks for your help! >> >> Value for 'dinamic_desc' field come from 'src_desc' field. I copy the >> value with: >> >> <copyField source="src_*" dest="dinamic_*"/> >> >> Seems like when I update a different field (field 'name') via atomic >> update, the copyField directive copies the value again from 'src_desc' to >> 'desc_field', instead of updating the value, like if 'desc_field' or >> 'desc_*' where multivalued. >> >> Cheers. >> ________________________________________ >> From: Alessandro Benedetti [benedetti.ale...@gmail.com] >> Sent: Wednesday, July 15, 2015 12:56 PM >> To: solr-user@lucene.apache.org >> Subject: Re: Does update field feature work in a schema with dynamic >> fields? >> >> Just tried, on Solr 5.1 and I get the proper behaviour. >> >> Actually where is the value for the dinamic_desc coming from ? >> >> I can not see it in the updates and actually it is not in my index. >> Are you sure you have not forgotten any detail ? >> >> Cheers >> >> 2015-07-15 11:48 GMT+01:00 Alessandro Benedetti < >> benedetti.ale...@gmail.com> >> : >> >> > This is kinda weird and looks a lot like a bug. >> > Let me try to reproduce it locally! >> > I let you know soon ! >> > >> > Cheers >> > >> > 2015-07-15 10:01 GMT+01:00 Martínez López, Alfonso <almlo...@indra.es>: >> > >> >> Hi, >> >> >> >> i'm using Solr 4.10.3, and i'm trying update a doc field using atomic >> >> update (http://wiki.apache.org/solr/Atomic_Updates). >> >> >> >> My schema.xml is like this: >> >> >> >> <!--Fields--> >> >> <field name="id" type="string" indexed="true" stored="true" >> >> required="true" /> >> >> <field name="name" type="string" indexed="true" stored="true" /> >> >> <field name="src_desc" type="string" indexed="true" stored="true" /> >> >> <field name="_version_" type="long" indexed="true" stored="true" / >> >> <!--Dynamic fields definition--> >> >> <dynamicField name="src_*" type="string" indexed="true" stored="true" >> >> multiValued="false" /> >> >> <dynamicField name="dinamic_*" type="string" indexed="true" >> stored="true" >> >> multiValued="false" /> >> >> <!--Copy fields--> >> >> <copyField source="src_*" dest="dinamic_*"/> >> >> >> >> >> >> I add a document with this command: >> >> >> >> >> >> >> >> curl http://<solr_host>:<sorl_port>/solr/default/update?commit=true -H >> >> "Content-Type: text/xml" --data-binary '<add><doc><field >> >> name="id">1</field><field name="name" >paco</field><field >> name="src_desc" >> >> >friend of mine</field></doc></add>' >> >> >> >> >> >> >> >> And later I update the field 'name' with this command: >> >> >> >> >> >> >> >> curl http://<solr_host>:<sorl_port>/solr/default/update?commit=true -H >> >> "Content-Type: text/xml" --data-binary '<add><doc><field >> >> name="id">1</field><field name="name" >> >> update="set">paquico</field></doc></add>' >> >> >> >> >> >> >> >> As I do so the doc i retrive from Solr is: >> >> >> >> >> >> >> >> <result name="response" numFound="1" start="0" maxScore="1.0"> >> >> <doc> >> >> <str name="id">1</str> >> >> <str name="name">paquico</str> >> >> <str name="src_desc">friend of mine</str> >> >> <arr name="dinamic_desc"> >> >> <str>friend of mine</str> >> >> <str>friend of mine</str> >> >> </arr> >> >> <long name="_version_">1506750859550130176</long> >> >> <float name="score">1.0</float> >> >> </doc> >> >> </result> >> >> >> >> >> >> >> >> So I get a non multivalued field (dinamic_desc) with multiple values :( >> >> >> >> >> >> >> >> >> >> >> >> ________________________________ >> >> Este correo electrónico y, en su caso, cualquier fichero anexo al >> mismo, >> >> contiene información de carácter confidencial exclusivamente dirigida >> a su >> >> destinatario o destinatarios. Si no es vd. el destinatario indicado, >> queda >> >> notificado que la lectura, utilización, divulgación y/o copia sin >> >> autorización está prohibida en virtud de la legislación vigente. En el >> caso >> >> de haber recibido este correo electrónico por error, se ruega notificar >> >> inmediatamente esta circunstancia mediante reenvío a la dirección >> >> electrónica del remitente. >> >> Evite imprimir este mensaje si no es estrictamente necesario. >> >> >> >> This email and any file attached to it (when applicable) contain(s) >> >> confidential information that is exclusively addressed to its >> recipient(s). >> >> If you are not the indicated recipient, you are informed that reading, >> >> using, disseminating and/or copying it without authorisation is >> forbidden >> >> in accordance with the legislation in effect. If you have received this >> >> email by mistake, please immediately notify the sender of the >> situation by >> >> resending it to their email address. >> >> Avoid printing this message if it is not absolutely necessary. >> >> >> > >> > >> > >> > -- >> > -------------------------- >> > >> > Benedetti Alessandro >> > Visiting card - http://about.me/alessandro_benedetti >> > Blog - http://alexbenedetti.blogspot.co.uk >> > >> > "Tyger, tyger burning bright >> > In the forests of the night, >> > What immortal hand or eye >> > Could frame thy fearful symmetry?" >> > >> > William Blake - Songs of Experience -1794 England >> > >> >> >> >> -- >> -------------------------- >> >> Benedetti Alessandro >> Visiting card - http://about.me/alessandro_benedetti >> Blog - http://alexbenedetti.blogspot.co.uk >> >> "Tyger, tyger burning bright >> In the forests of the night, >> What immortal hand or eye >> Could frame thy fearful symmetry?" >> >> William Blake - Songs of Experience -1794 England >> >> Este correo electrónico y, en su caso, cualquier fichero anexo al mismo, >> contiene información de carácter confidencial exclusivamente dirigida a su >> destinatario o destinatarios. Si no es vd. el destinatario indicado, queda >> notificado que la lectura, utilización, divulgación y/o copia sin >> autorización está prohibida en virtud de la legislación vigente. En el caso >> de haber recibido este correo electrónico por error, se ruega notificar >> inmediatamente esta circunstancia mediante reenvío a la dirección >> electrónica del remitente. >> Evite imprimir este mensaje si no es estrictamente necesario. >> >> This email and any file attached to it (when applicable) contain(s) >> confidential information that is exclusively addressed to its recipient(s). >> If you are not the indicated recipient, you are informed that reading, >> using, disseminating and/or copying it without authorisation is forbidden >> in accordance with the legislation in effect. If you have received this >> email by mistake, please immediately notify the sender of the situation by >> resending it to their email address. >> Avoid printing this message if it is not absolutely necessary. >> > > > > -- > -------------------------- > > Benedetti Alessandro > Visiting card - http://about.me/alessandro_benedetti > Blog - http://alexbenedetti.blogspot.co.uk > > "Tyger, tyger burning bright > In the forests of the night, > What immortal hand or eye > Could frame thy fearful symmetry?" > > William Blake - Songs of Experience -1794 England > -- -------------------------- Benedetti Alessandro Visiting card - http://about.me/alessandro_benedetti Blog - http://alexbenedetti.blogspot.co.uk "Tyger, tyger burning bright In the forests of the night, What immortal hand or eye Could frame thy fearful symmetry?" William Blake - Songs of Experience -1794 England Este correo electrónico y, en su caso, cualquier fichero anexo al mismo, contiene información de carácter confidencial exclusivamente dirigida a su destinatario o destinatarios. Si no es vd. el destinatario indicado, queda notificado que la lectura, utilización, divulgación y/o copia sin autorización está prohibida en virtud de la legislación vigente. En el caso de haber recibido este correo electrónico por error, se ruega notificar inmediatamente esta circunstancia mediante reenvío a la dirección electrónica del remitente. Evite imprimir este mensaje si no es estrictamente necesario. This email and any file attached to it (when applicable) contain(s) confidential information that is exclusively addressed to its recipient(s). If you are not the indicated recipient, you are informed that reading, using, disseminating and/or copying it without authorisation is forbidden in accordance with the legislation in effect. If you have received this email by mistake, please immediately notify the sender of the situation by resending it to their email address. Avoid printing this message if it is not absolutely necessary.