You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Michael Hu <mh...@vmware.com> on 2018/02/06 19:05:41 UTC

How can I prevent adding duplicated copyfield into managed schema

Hi Solr experts:


Question: how can I prevent multiple concurrent requests adding the same duplicated copyfield into managed schema? (Note: I am using Solr 6.6.2)


User case: For a new field named srcField, I need to create another field named destField, and a new copyField with srcField as source and destField as destination; and add srcField, descField, and the copyField into schema using following APIs:


  *   For add fields: IndexSchema.addFields(Collection<SchemaField>)
  *   For add copyField: Index.addCopyFields(Map<String, Collection<String>, boolean)


Adding the same field multiple time is not the issue since "field" is maintained as a map with field name as the key; HOWEVER, adding the same copyfield multiple time results duplicated copyfield entries because the value of the "copyFieldsMap" is a list (with source field name as the key)


For a single core, I think I can synchronizing the core schema update lock and check the latest core schema again before invoking above APIs to prevent this case. Is there better way to solve this issue?


HOWEVER, how can I prevent this issue with multiple cores sharing the same schema (i.e. those cores have the same instance directory containing managed-schema.xml) because each core has its own schema update lock. Above approach does not work for this case.


Please advise! Thank you so much!


--Michael

Re: How can I prevent adding duplicated copyfield into managed schema

Posted by Wendy2 <we...@rcsb.org>.
What if you include the core name as part of the direct path?
In my practice, managed-schema file is stored under ~/solr/coreName, so it
is core specific and will never be shared with other cores. 

Wendy  



--
Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html