Skip to content

Commit a96c237

Browse files
committed
explicitly convert numeric values when adding them to a Solr doc;
refs #26704
1 parent daa0020 commit a96c237

File tree

1 file changed

+33
-5
lines changed

1 file changed

+33
-5
lines changed

goobi-viewer-indexer/src/main/java/io/goobi/viewer/indexer/helper/SolrSearchIndex.java

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,40 @@ public static SolrInputDocument createDocument(List<LuceneField> luceneFields) {
232232
continue;
233233
}
234234

235-
// Do not pass a boost value because starting with Solr 3.6, adding an index-time boost to primitive field types will cause
236-
// the commit to fail
237-
doc.addField(luceneField.getField(), luceneField.getValue());
235+
// Explicitly use numeric value in doc, where applicable
236+
switch (luceneField.getField()) {
237+
case SolrConstants.CENTURY:
238+
case SolrConstants.CURRENTNOSORT:
239+
case SolrConstants.MONTHDAY:
240+
case SolrConstants.DATECREATED:
241+
case SolrConstants.DATEINDEXED:
242+
case SolrConstants.DATEUPDATED:
243+
case SolrConstants.NUMVOLUMES:
244+
case SolrConstants.YEAR:
245+
case SolrConstants.YEARMONTH:
246+
case SolrConstants.YEARMONTHDAY:
247+
doc.addField(luceneField.getField(), Long.parseLong(luceneField.getValue()));
248+
break;
249+
case SolrConstants.HEIGHT:
250+
case SolrConstants.NUMPAGES:
251+
case SolrConstants.ORDER:
252+
case SolrConstants.THUMBPAGENO:
253+
case SolrConstants.WIDTH:
254+
doc.addField(luceneField.getField(), Integer.parseInt(luceneField.getValue()));
255+
break;
256+
default:
257+
if (luceneField.getField().startsWith(SolrConstants.PREFIX_MDNUM) || luceneField.getField().startsWith("SORTNUM_")) {
258+
doc.addField(luceneField.getField(), Long.parseLong(luceneField.getValue()));
259+
} else if (luceneField.getField().startsWith("GROUPORDER_")) {
260+
doc.addField(luceneField.getField(), Integer.parseInt(luceneField.getValue()));
261+
} else {
262+
doc.addField(luceneField.getField(), luceneField.getValue());
263+
}
264+
}
238265
}
239266

240267
return doc;
268+
241269
}
242270

243271
/**
@@ -637,9 +665,9 @@ public SolrInputDocument checkAndCreateGroupDoc(String groupIdField, String grou
637665
doc.setField(SolrConstants.GROUPFIELD, oldDoc.getFieldValue(SolrConstants.IDDOC));
638666
}
639667
doc.setField(SolrConstants.DOCTYPE, DocType.GROUP.name());
640-
doc.setField(SolrConstants.DATECREATED, oldDoc.getFieldValue(SolrConstants.DATECREATED));
668+
doc.setField(SolrConstants.DATECREATED, Long.parseLong(String.valueOf(oldDoc.getFieldValue(SolrConstants.DATECREATED))));
641669
}
642-
doc.setField(SolrConstants.DATEUPDATED, now);
670+
doc.setField(SolrConstants.DATEUPDATED, Long.valueOf(now));
643671
doc.setField(SolrConstants.PI, groupId);
644672
doc.setField(SolrConstants.PI_TOPSTRUCT, groupId);
645673
doc.setField(SolrConstants.GROUPTYPE, groupIdField);

0 commit comments

Comments
 (0)