@@ -0,0 +1,2324 @@
+package de.tblsoft.solr.pipeline.filter;%0A%0Aimport com.google.common.base.Strings;%0Aimport de.tblsoft.solr.pipeline.AbstractFilter;%0Aimport de.tblsoft.solr.pipeline.bean.Document;%0Aimport de.tblsoft.solr.pipeline.bean.Field;%0Aimport de.tblsoft.solr.util.DocumentUtils;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0Aimport java.util.regex.Pattern;%0A%0A/**%0A * Created by tblsoft 18.05.17.%0A */%0Apublic class KeyValueSplitterFilter extends AbstractFilter %7B%0A%0A    private String fieldName;%0A    private String delimiter;%0A    private String keyValueDelimiter;%0A    private String keyPrefix;%0A    private boolean normalizeKey;%0A%0A%0A    @Override%0A    public void init() %7B%0A        fieldName = getProperty(%22fieldName%22, null);%0A        verify(fieldName, %22For the KeyValueSplitterFilter a fieldName must be defined.%22);%0A        delimiter = getProperty(%22delimiter%22, %22%7C%22);%0A        verify(delimiter, %22For the KeyValueSplitterFilter a delimiter must be defined.%22);%0A        keyValueDelimiter = getProperty(%22keyValueDelimiter%22, %22=%22);%0A        verify(keyValueDelimiter, %22For the KeyValueSplitterFilter a keyValueDelimiter must be defined.%22);%0A        keyPrefix = getProperty(%22keyPrefix%22, %22%22);%0A        normalizeKey = getPropertyAsBoolean(%22normalizeKey%22, true);%0A%0A        super.init();%0A    %7D%0A%0A%0A    @Override%0A    public void document(Document document) %7B%0A%0A        List%3CString%3E values = document.getFieldValues(fieldName, new ArrayList%3CString%3E());%0A        for(String value: values) %7B%0A            String%5B%5D splittedValues = value.split(Pattern.quote(delimiter));%0A            for(String splittedValue : splittedValues) %7B%0A                Field field = processKeyValue(splittedValue);%0A                if(field != null) %7B%0A                    document.addField(field);%0A                %7D%0A            %7D%0A        %7D%0A        super.document(document);%0A%0A    %7D%0A%0A    Field processKeyValue(String keyValue) %7B%0A        if(Strings.isNullOrEmpty(keyValue)) %7B%0A            return null;%0A        %7D%0A        String%5B%5D splittedValue = keyValue.split(Pattern.quote(keyValueDelimiter));%0A        if(splittedValue.length != 2) %7B%0A            return null;%0A        %7D%0A        String key = keyPrefix + splittedValue%5B0%5D;%0A%0A        if(normalizeKey) %7B%0A            key = DocumentUtils.normalizeFieldKey(key);%0A        %7D%0A        Field field = new Field(key, splittedValue%5B1%5D);%0A        return field;%0A%0A    %7D%0A%0A%7D%0A

add key value splitter filter