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

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

Introduction

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

Prototype

public Map<String, T> asShallowMap() 

Source Link

Usage

From source file:org.craftercms.search.service.impl.SolrAdminService.java

License:Open Source License

@Override
public Map<String, Object> getIndexInfo(String id) throws SearchException {
    CoreAdminRequest request = new CoreAdminRequest();
    request.setCoreName(id);//from www.ja  v  a  2  s . co  m
    request.setIndexInfoNeeded(true);
    request.setAction(CoreAdminParams.CoreAdminAction.STATUS);

    try {
        CoreAdminResponse response = request.process(solrClient);
        Map<String, Object> info = null;

        if (response != null) {
            NamedList<Object> status = response.getCoreStatus(id);
            if (status != null) {
                info = status.asShallowMap();
            }
        }

        if (MapUtils.isNotEmpty(info)) {
            return info;
        } else {
            throw new IndexNotFoundException("Index '" + id + "' not ");
        }
    } catch (SolrServerException | IOException e) {
        throw new SearchException(id, "Failed to get core info", e);
    }
}