Example usage for org.apache.solr.common.util NamedList get

List of usage examples for org.apache.solr.common.util NamedList get

Introduction

In this page you can find the example usage for org.apache.solr.common.util NamedList get.

Prototype

public T get(String name, int start) 

Source Link

Document

Gets the value for the first instance of the specified name found starting at the specified index.

Usage

From source file:org.topicquests.solr.uima.processor.SolrUIMAConfigurationReader.java

License:Apache License

@SuppressWarnings("rawtypes")
private Map<String, Map<String, MapField>> readTypesFeaturesFieldsMapping() {
    Map<String, Map<String, MapField>> map = new HashMap<String, Map<String, MapField>>();

    NamedList fieldMappings = (NamedList) args.get("fieldMappings");
    /* iterate over UIMA types */
    for (int i = 0; i < fieldMappings.size(); i++) {
        NamedList type = (NamedList) fieldMappings.get("type", i);
        String typeName = (String) type.get("name");

        Map<String, MapField> subMap = new HashMap<String, MapField>();
        /* iterate over mapping definitions */
        for (int j = 0; j < type.size() - 1; j++) {
            NamedList mapping = (NamedList) type.get("mapping", j + 1);
            String featureName = (String) mapping.get("feature");
            String fieldNameFeature = null;
            String mappedFieldName = (String) mapping.get("field");
            if (mappedFieldName == null) {
                fieldNameFeature = (String) mapping.get("fieldNameFeature");
                mappedFieldName = (String) mapping.get("dynamicField");
            }/*from ww  w. jav  a  2s . c  o  m*/
            if (mappedFieldName == null)
                throw new RuntimeException(
                        "either of field or dynamicField should be defined for feature " + featureName);
            MapField mapField = new MapField(mappedFieldName, fieldNameFeature);
            subMap.put(featureName, mapField);
        }
        map.put(typeName, subMap);
    }
    return map;
}