Project

General

Profile

« Previous | Next » 

Revision 10114

Added by Jing Tao about 8 years ago

Add the code to handle the merge-needed fields having multiple pairs.

View differences:

metacat-index/src/main/java/edu/ucsb/nceas/metacat/index/SolrIndex.java
33 33
import java.util.List;
34 34
import java.util.Map;
35 35
import java.util.Set;
36
import java.util.Vector;
36 37

  
37 38
import javax.xml.parsers.DocumentBuilder;
38 39
import javax.xml.parsers.DocumentBuilderFactory;
......
308 309
        if (indexedDocument == null || indexedDocument.getFieldList().size() <= 0) {
309 310
            return indexDocument;
310 311
        } else {
312
            Vector<SolrElementField> mergeNeededFields = new Vector<SolrElementField>(); 
311 313
            for (SolrElementField field : indexedDocument.getFieldList()) {
312 314
                if ((field.getName().equals(SolrElementField.FIELD_ISDOCUMENTEDBY)
313 315
                        || field.getName().equals(SolrElementField.FIELD_DOCUMENTS) || field
......
316 318
                    indexDocument.addField(field);
317 319
                } else if (!indexSchema.isCopyFieldTarget(indexSchema.getField(field.getName())) && !indexDocument.hasField(field.getName()) && !isSystemMetadataField(field.getName())) {
318 320
                    // we don't merge the system metadata field since they can be removed.
321
                    log.debug("SolrIndex.mergeWithIndexedDocument - put the merge-needed existing solr field "+field.getName()+" with value "+field.getValue()+" from the solr server to a vector. We will merge it later.");
322
                    //indexDocument.addField(field);
323
                    mergeNeededFields.add(field);//record this name since we can have mutiple name/value for the same name. See https://projects.ecoinformatics.org/ecoinfo/issues/7168
324
                } 
325
            }
326
            if(mergeNeededFields != null) {
327
                for(SolrElementField field: mergeNeededFields) {
319 328
                    log.debug("SolrIndex.mergeWithIndexedDocument - merge the existing solr field "+field.getName()+" with value "+field.getValue()+" from the solr server to the currently processing document of "+indexDocument.getIdentifier());
320 329
                    indexDocument.addField(field);
321 330
                }
322 331
            }
323

  
324 332
            indexDocument.setMerged(true);
325 333
            return indexDocument;
326 334
        }

Also available in: Unified diff