core/src/main/java/com/digitalpebble/stormcrawler/indexing/AbstractIndexerBolt.java
protected Map<String, String[]> filterMetadata(Metadata meta) {

        Pattern indexValuePattern = Pattern.compile("\\[(\\d+)\\]");

        Map<String, String[]> fieldVals = new HashMap<>();
        Iterator<Entry<String, String>> iter = metadata2field.entrySet()
                .iterator();
        while (iter.hasNext()) {
            Entry<String, String> entry = iter.next();
            // check whether we want a specific value or all of them?
            int index = -1;
            String key = entry.getKey();
            Matcher match = indexValuePattern.matcher(key);
            if (match.find()) {
                index = Integer.parseInt(match.group(1));
                key = key.substring(0, match.start());
            }
            String[] values = meta.getValues(key);
            // not found
            if (values == null || values.length == 0)
                continue;
            // want a value index that it outside the range given
            if (index >= values.length)
                continue;
            // store all values available
            if (index == -1)
                fieldVals.put(entry.getValue(), values);
            // or only the one we want
            else
                fieldVals.put(entry.getValue(), new String[] { values[index] });
        }

        return fieldVals;
    }
protected Map<String, String[]> filterMetadata(Metadata meta) {

        Pattern indexValuePattern = Pattern.compile("\\[(\\d+)\\]");

        Map<String, String[]> fieldVals = new HashMap<>();
        Iterator<Entry<String, String>> iter = metadata2field.entrySet()
                .iterator();
        while (iter.hasNext()) {
            Entry<String, String> entry = iter.next();
            // check whether we want a specific value or all of them?
            int index = -1;
            String key = entry.getKey();
            Matcher match = indexValuePattern.matcher(key);
            if (match.find()) {
                index = Integer.parseInt(match.group(1));
                key = key.substring(0, match.start());
            }
            String[] values = meta.getValues(key);
            // not found
            if (values == null || values.length == 0)
                continue;
            // want a value index that it outside the range given
            if (index >= values.length)
                continue;
            // store all values available
            if (index == -1)
                fieldVals.put(entry.getValue(), values);
            // or only the one we want
            else
                fieldVals.put(entry.getValue(), new String[] { values[index] });
        }

        return fieldVals;
    }
protected Map < String , String [ ] > filterMetadata ( Metadata meta ) { Pattern indexValuePattern = Pattern . compile ( "\\[(\\d+)\\]" ) ; Map < String , String [ ] > fieldVals = new HashMap <> ( ) ; Iterator < Entry < String , String > > iter = metadata2field . entrySet ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { Entry < String , String > entry = iter . next ( ) ; // check whether we want a specific value or all of them? int index = - 1 ; String key = entry . getKey ( ) ; Matcher match = indexValuePattern . matcher ( key ) ; if ( match . find ( ) ) { index = Integer . parseInt ( match . group ( 1 ) ) ; key = key . substring ( 0 , match . start ( ) ) ; } String [ ] values = meta . getValues ( key ) ; // not found if ( values == null || values . length == 0 ) continue ; // want a value index that it outside the range given if ( index >= values . length ) continue ; // store all values available if ( index == - 1 ) fieldVals . put ( entry . getValue ( ) , values ) ; // or only the one we want else fieldVals . put ( entry . getValue ( ) , new String [ ] { values [ index ] } ) ; } return fieldVals ; }
Returns a mapping field name / values for the metadata to index *
Returns a mapping field name / values for the metadata to index *