Added missing vocabulary navigator increment on results from RWI

pull/167/head
luccioman 7 years ago
parent 46c9da6428
commit 1b90479a76

@ -1219,27 +1219,37 @@ public final class SearchEvent implements ScoreMapUpdatesListener {
for (String vocName : genericFacets) { for (String vocName : genericFacets) {
final String fieldName = CollectionSchema.VOCABULARY_PREFIX + vocName + CollectionSchema.VOCABULARY_TERMS_SUFFIX; final String fieldName = CollectionSchema.VOCABULARY_PREFIX + vocName + CollectionSchema.VOCABULARY_TERMS_SUFFIX;
if (facets == null || !facets.containsKey(fieldName)) { if (facets == null || !facets.containsKey(fieldName)) {
Object docValue = doc.getFieldValue(fieldName); incrementVocNavigator(doc, vocName, fieldName);
if(docValue instanceof String) { }
ScoreMap<String> vocNav = this.vocabularyNavigator.get(vocName); }
if (vocNav == null) { }
vocNav = new ConcurrentScoreMap<String>(); }
this.vocabularyNavigator.put(vocName, vocNav);
} /**
vocNav.inc((String)docValue); * Increment a vocabulary navigator with the given document
} else if(docValue instanceof Collection) { * @param doc a document entry. Must not be null.
if (!((Collection<?>) docValue).isEmpty()) { * @param vocName the name of the vocabulary. Must not be null.
ScoreMap<String> vocNav = this.vocabularyNavigator.get(vocName); * @param fieldName the name of the field eventually holding the vocabulary information in the document entry
if (vocNav == null) { */
vocNav = new ConcurrentScoreMap<String>(); protected void incrementVocNavigator(final URIMetadataNode doc, final String vocName, final String fieldName) {
this.vocabularyNavigator.put(vocName, vocNav); final Object docValue = doc.getFieldValue(fieldName);
} if(docValue instanceof String) {
for (Object singleDocValue : (Collection<?>) docValue) { ScoreMap<String> vocNav = this.vocabularyNavigator.get(vocName);
if (singleDocValue instanceof String) { if (vocNav == null) {
vocNav.inc((String) singleDocValue); vocNav = new ConcurrentScoreMap<String>();
} this.vocabularyNavigator.put(vocName, vocNav);
} }
} vocNav.inc((String)docValue);
} else if(docValue instanceof Collection) {
if (!((Collection<?>) docValue).isEmpty()) {
ScoreMap<String> vocNav = this.vocabularyNavigator.get(vocName);
if (vocNav == null) {
vocNav = new ConcurrentScoreMap<String>();
this.vocabularyNavigator.put(vocName, vocNav);
}
for (final Object singleDocValue : (Collection<?>) docValue) {
if (singleDocValue instanceof String) {
vocNav.inc((String) singleDocValue);
} }
} }
} }
@ -1573,6 +1583,20 @@ public final class SearchEvent implements ScoreMapUpdatesListener {
} }
} }
} }
// handle the vocabulary navigator
if (this.vocabularyNavigator != null) {
Set<String> genericFacets = new LinkedHashSet<>();
for (Tagging v : LibraryProvider.autotagging.getVocabularies()) {
genericFacets.add(v.getName());
}
genericFacets.addAll(ProbabilisticClassifier.getContextNames());
for (final String vocName : genericFacets) {
final String fieldName = CollectionSchema.VOCABULARY_PREFIX + vocName
+ CollectionSchema.VOCABULARY_TERMS_SUFFIX;
incrementVocNavigator(page, vocName, fieldName);
}
}
return page; // accept url return page; // accept url
} }

Loading…
Cancel
Save