Project

General

Profile

« Previous | Next » 

Revision 8805

handle multiple subprocessors (RDF and ORE) before the object gets indexed by making sure to merge the solr doc map before submitting to the index.

View differences:

metacat-index/src/main/java/edu/ucsb/nceas/metacat/index/annotation/RdfXmlSubprocessor.java
107 107
        for (SolrDoc processedDoc : processedDocs) {
108 108
            processedDocsMap.put(processedDoc.getIdentifier(), processedDoc);
109 109
        }
110
        return processedDocsMap;
110
        // make sure to merge any docs that are currently being processed
111
        Map<String, SolrDoc> mergedDocuments = mergeDocs(docs, processedDocsMap);
112
        return mergedDocuments;
111 113
    }
112 114

  
113 115
    private InputStream toInputStream(Document doc) throws TransformerConfigurationException, TransformerException, TransformerFactoryConfigurationError {
......
213 215
        return list;
214 216
    }
215 217
    
216
    private Map<String, SolrDoc> mergeDocs(Map<String, SolrDoc> pending, Map<String, SolrDoc> existing) {
218
    private Map<String, SolrDoc> mergeDocs(Map<String, SolrDoc> pending, Map<String, SolrDoc> existing) throws Exception {
219
    	IndexSchema indexSchema = SolrQueryServiceController.getInstance().getSchema();
220

  
217 221
    	Map<String, SolrDoc> merged = new HashMap<String, SolrDoc>();
218 222
    	Iterator<String> pendingIter = pending.keySet().iterator();
219 223
    	while (pendingIter.hasNext()) {
......
233 237
    			if (field.getName().equals(SolrElementField.FIELD_ID) && mergedDoc.hasField(SolrElementField.FIELD_ID)) {
234 238
    				continue;
235 239
    			}
236
				mergedDoc.addField(field);
237
				
240
    			// don't transfer the copyTo fields, otherwise there are errors
241
				if (indexSchema.isCopyFieldTarget(indexSchema.getField(field.getName()))) {
242
					continue;
243
				}
244
				// only add if we don't already have it
245
				if (!mergedDoc.hasFieldWithValue(field.getName(), field.getValue())) {
246
					mergedDoc.addField(field);
247
				}	
238 248
			}
239 249
    		
240 250
    		// include in results

Also available in: Unified diff