Example usage for org.apache.solr.client.solrj SolrQuery setTermsLowerInclusive

List of usage examples for org.apache.solr.client.solrj SolrQuery setTermsLowerInclusive

Introduction

In this page you can find the example usage for org.apache.solr.client.solrj SolrQuery setTermsLowerInclusive.

Prototype

public SolrQuery setTermsLowerInclusive(boolean b) 

Source Link

Usage

From source file:cz.incad.vdk.client.tools.Search.java

License:Open Source License

public JSONArray getSuggest() {
    try {/*  w  w  w . j a v  a 2s  . c o m*/
        String q = req.getParameter("term");
        SolrQuery query = new SolrQuery();
        if (q == null || q.equals("")) {
            return new JSONArray();
        }

        query.setParam(CommonParams.QT, "/terms");
        query.setTerms(true);
        query.setTermsPrefix(q.toUpperCase());
        query.setTermsLowerInclusive(true);
        query.addTermsField("title_suggest");
        JSONArray ja = new JSONObject(IndexerQuery.terms(query)).getJSONObject("terms")
                .getJSONArray("title_suggest");
        JSONArray ret = new JSONArray();
        for (int i = 0; i < ja.length(); i = i + 2) {
            String val = ja.getString(i);
            ret.put(new JSONObject().put("value", val).put("label", val.substring(val.indexOf("##") + 2)));
        }

        return ret;
    } catch (IOException ex) {
        Logger.getLogger(Search.class.getName()).log(Level.SEVERE, null, ex);
        return new JSONArray();
    }
}