Skip to content

Commit

Permalink
also explicitly case event numeric fields; refs #26704
Browse files Browse the repository at this point in the history
  • Loading branch information
Keelhaul committed Jan 27, 2025
1 parent a96c237 commit 01560dd
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ private List<SolrInputDocument> generateEvents(IndexObject indexObj) throws Fata
}

for (LuceneField field : fields) {
eventDoc.addField(field.getField(), field.getValue());
SolrSearchIndex.addFieldToDoc(field, eventDoc);
logger.debug("Added {}:{} to event '{}'.", field.getField(), field.getValue(), type);

// Check whether this field is configured to be added as a sort field to topstruct
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,43 +231,58 @@ public static SolrInputDocument createDocument(List<LuceneField> luceneFields) {
if (luceneField.isSkip() || luceneField.getValue() == null) {
continue;
}

// Explicitly use numeric value in doc, where applicable
switch (luceneField.getField()) {
case SolrConstants.CENTURY:
case SolrConstants.CURRENTNOSORT:
case SolrConstants.MONTHDAY:
case SolrConstants.DATECREATED:
case SolrConstants.DATEINDEXED:
case SolrConstants.DATEUPDATED:
case SolrConstants.NUMVOLUMES:
case SolrConstants.YEAR:
case SolrConstants.YEARMONTH:
case SolrConstants.YEARMONTHDAY:
doc.addField(luceneField.getField(), Long.parseLong(luceneField.getValue()));
break;
case SolrConstants.HEIGHT:
case SolrConstants.NUMPAGES:
case SolrConstants.ORDER:
case SolrConstants.THUMBPAGENO:
case SolrConstants.WIDTH:
doc.addField(luceneField.getField(), Integer.parseInt(luceneField.getValue()));
break;
default:
if (luceneField.getField().startsWith(SolrConstants.PREFIX_MDNUM) || luceneField.getField().startsWith("SORTNUM_")) {
doc.addField(luceneField.getField(), Long.parseLong(luceneField.getValue()));
} else if (luceneField.getField().startsWith("GROUPORDER_")) {
doc.addField(luceneField.getField(), Integer.parseInt(luceneField.getValue()));
} else {
doc.addField(luceneField.getField(), luceneField.getValue());
}
}
addFieldToDoc(luceneField, doc);
}

return doc;

}

/**
*
* @param luceneField
* @param doc
*/
public static void addFieldToDoc(LuceneField luceneField, SolrInputDocument doc) {
if (luceneField == null) {
throw new IllegalArgumentException("luceneField may not be null");
}
if (doc == null) {
throw new IllegalArgumentException("doc may not be null");
}

// Explicitly use numeric value in doc, where applicable
switch (luceneField.getField()) {
case SolrConstants.CENTURY:
case SolrConstants.CURRENTNOSORT:
case SolrConstants.MONTHDAY:
case SolrConstants.DATECREATED:
case SolrConstants.DATEINDEXED:
case SolrConstants.DATEUPDATED:
case SolrConstants.NUMVOLUMES:
case SolrConstants.YEAR:
case SolrConstants.YEARMONTH:
case SolrConstants.YEARMONTHDAY:
doc.addField(luceneField.getField(), Long.parseLong(luceneField.getValue()));
break;
case SolrConstants.HEIGHT:
case SolrConstants.NUMPAGES:
case SolrConstants.ORDER:
case SolrConstants.THUMBPAGENO:
case SolrConstants.WIDTH:
doc.addField(luceneField.getField(), Integer.parseInt(luceneField.getValue()));
break;
default:
if (luceneField.getField().startsWith(SolrConstants.PREFIX_MDNUM) || luceneField.getField().startsWith("SORTNUM_")) {
doc.addField(luceneField.getField(), Long.parseLong(luceneField.getValue()));
} else if (luceneField.getField().startsWith("GROUPORDER_")) {
doc.addField(luceneField.getField(), Integer.parseInt(luceneField.getValue()));
} else {
doc.addField(luceneField.getField(), luceneField.getValue());
}
}
}

/**
* <p>
* findCurrentDataRepository.
Expand Down

0 comments on commit 01560dd

Please sign in to comment.