in core/src/main/java/org/apache/stormcrawler/indexing/AbstractIndexerBolt.java [203:247]
protected Map<String, String[]> filterMetadata(Metadata meta) {
Map<String, String[]> fieldVals = new HashMap<>();
for (Key key : metadata2field) {
Set<String> matchingKeys = new HashSet<>();
// if it is a glob - look for all matching entries in the metadata
if (key.isGlob()) {
matchingKeys = meta.keySet(key.getKey());
} else {
matchingKeys.add(key.getKey());
}
for (String matchingKey : matchingKeys) {
String[] values = meta.getValues(matchingKey);
String label = matchingKey;
// won't be the case for globs
if (key.getAlias() != null) {
label = key.getAlias();
}
// not found
if (values == null || values.length == 0) {
continue;
}
// check whether we want a specific value or all of them?
int index = key.index;
// want a value index that it outside the range given
if (index >= values.length) {
continue;
}
// store all values available
if (index == -1) {
fieldVals.put(label, values);
}
// or only the one we want
else {
fieldVals.put(label, new String[] {values[index]});
}
}
}
return fieldVals;
}