Example usage for org.apache.solr.common.util StrUtils splitSmart

List of usage examples for org.apache.solr.common.util StrUtils splitSmart

Introduction

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

Prototype

public static List<String> splitSmart(String s, char separator) 

Source Link

Usage

From source file:fi.nationallibrary.ndl.solr.request.RangeFieldFacets.java

License:Apache License

void parseParams(String type, String param) throws ParseException, IOException {
    localParams = QueryParsing.getLocalParams(param, req.getParams());
    base = docs;//from ww  w  . j ava  2  s .co m
    facetValue = param;
    key = param;

    if (localParams == null)
        return;

    // remove local params unless it's a query
    if (type != FacetParams.FACET_QUERY) {
        facetValue = localParams.get(CommonParams.VALUE);
    }

    // reset set the default key now that localParams have been removed
    key = facetValue;

    // allow explicit set of the key
    key = localParams.get(CommonParams.OUTPUT_KEY, key);

    // figure out if we need a new base DocSet
    String excludeStr = localParams.get(CommonParams.EXCLUDE);
    if (excludeStr == null)
        return;

    Map tagMap = (Map) req.getContext().get("tags");
    if (tagMap != null && rb != null) {
        List<String> excludeTagList = StrUtils.splitSmart(excludeStr, ',');

        IdentityHashMap<Query, Boolean> excludeSet = new IdentityHashMap<Query, Boolean>();
        for (String excludeTag : excludeTagList) {
            Object olst = tagMap.get(excludeTag);
            // tagMap has entries of List<String,List<QParser>>, but subject to change in the future
            if (!(olst instanceof Collection))
                continue;
            for (Object o : (Collection) olst) {
                if (!(o instanceof QParser))
                    continue;
                QParser qp = (QParser) o;
                excludeSet.put(qp.getQuery(), Boolean.TRUE);
            }
        }
        if (excludeSet.size() == 0)
            return;

        List<Query> qlist = new ArrayList<Query>();

        // add the base query
        if (!excludeSet.containsKey(rb.getQuery())) {
            qlist.add(rb.getQuery());
        }

        // add the filters
        if (rb.getFilters() != null) {
            for (Query q : rb.getFilters()) {
                if (!excludeSet.containsKey(q)) {
                    qlist.add(q);
                }
            }
        }

        // get the new base docset for this facet
        base = searcher.getDocSet(qlist);
    }

}