Example usage for org.apache.solr.common.params TermsParams TERMS_PREFIX_STR

List of usage examples for org.apache.solr.common.params TermsParams TERMS_PREFIX_STR

Introduction

In this page you can find the example usage for org.apache.solr.common.params TermsParams TERMS_PREFIX_STR.

Prototype

String TERMS_PREFIX_STR

To view the source code for org.apache.solr.common.params TermsParams TERMS_PREFIX_STR.

Click Source Link

Usage

From source file:de.kp.ames.web.core.search.SearcherImpl.java

License:Open Source License

public String suggest(String request, String start, String limit) throws Exception {

    /*/* ww  w. ja v  a2 s .  co  m*/
     * Retrieve terms
     */
    SolrQuery query = new SolrQuery();

    query.setParam(CommonParams.QT, "/terms");
    query.setParam(TermsParams.TERMS, true);

    query.setParam(TermsParams.TERMS_LIMIT, SearchConstants.TERMS_LIMIT);

    query.setParam(TermsParams.TERMS_FIELD, SearchConstants.TERMS_FIELD);
    query.setParam(TermsParams.TERMS_PREFIX_STR, request);

    QueryResponse response = solrProxy.executeQuery(query);
    NamedList<Object> terms = getTerms(response);

    JSONArray jTerms = getTermValues(SearchConstants.TERMS_FIELD, terms);

    /*
     * Render result for DataSource
     */
    return jTerms.toString();

}