Project

General

Profile

« Previous | Next » 

Revision 8496

check for existing documents - don't assume it exists.

View differences:

metacat-index/src/main/java/edu/ucsb/nceas/metacat/index/resourcemap/ResourceMapSubprocessor.java
150 150
			String query = QUERY + "\"" + id + "\"";
151 151
			SolrParams solrParams = SolrRequestParsers.parseQueryString(query);
152 152
			QueryResponse qr = solrServer.query(solrParams);
153
			SolrDocument orig = qr.getResults().get(0);
154
			IndexSchema indexSchema = SolrQueryServiceController.getInstance().getSchema();
155
			for (String fieldName : orig.getFieldNames()) {
156
				// don't transfer the copyTo fields, otherwise there are errors
157
				if (indexSchema.isCopyFieldTarget(indexSchema.getField(fieldName))) {
158
					continue;
159
				}
160
				for (Object value : orig.getFieldValues(fieldName)) {
161
					String stringValue = value.toString();
162
					// special handling for dates in ISO 8601
163
					if (value instanceof Date) {
164
						stringValue = DateTimeMarshaller.serializeDateToUTC((Date) value);
165
						SolrDateConverter converter = new SolrDateConverter();
166
						stringValue = converter.convert(stringValue);
153
			if (qr.getResults().size() > 0) {
154
				SolrDocument orig = qr.getResults().get(0);
155
				IndexSchema indexSchema = SolrQueryServiceController.getInstance().getSchema();
156
				for (String fieldName : orig.getFieldNames()) {
157
					// don't transfer the copyTo fields, otherwise there are errors
158
					if (indexSchema.isCopyFieldTarget(indexSchema.getField(fieldName))) {
159
						continue;
167 160
					}
168
					SolrElementField field = new SolrElementField(fieldName, stringValue);
169
					log.debug("Adding field: " + fieldName);
170
					doc.addField(field);
161
					for (Object value : orig.getFieldValues(fieldName)) {
162
						String stringValue = value.toString();
163
						// special handling for dates in ISO 8601
164
						if (value instanceof Date) {
165
							stringValue = DateTimeMarshaller.serializeDateToUTC((Date) value);
166
							SolrDateConverter converter = new SolrDateConverter();
167
							stringValue = converter.convert(stringValue);
168
						}
169
						SolrElementField field = new SolrElementField(fieldName, stringValue);
170
						log.debug("Adding field: " + fieldName);
171
						doc.addField(field);
172
					}
171 173
				}
172 174
			}
173 175

  

Also available in: Unified diff