Please help me with this:

I have this code which return term frequency from techproducts example:

/////////////////////////////////////////////////////////////////////////////////////////////
import java.util.List;

import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.client.solrj.response.TermsResponse;

public class test4 {
    public static void main(String[] args) throws Exception {
        String urlString = "http://localhost:8983/solr/techproducts";;
        SolrClient solr = new HttpSolrClient.Builder(urlString).build();

        SolrQuery query = new SolrQuery();
        query.setTerms(true);
        query.addTermsField("name");
        SolrRequest<QueryResponse> req = new QueryRequest(query);
        QueryResponse rsp = req.process(solr);

        System.out.println(rsp);

        System.out.println("numFound: " + rsp.getResults().getNumFound());

        TermsResponse termResp =rsp.getTermsResponse();
        List<TermsResponse.Term> terms = termResp.getTerms("name");
        System.out.print("size="+ terms.size());
    }
}
/////////////////////////////////////////////////////////////////////////////////////////////

the result is 0 records I don't know why?? this is what I got:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further
details.
{responseHeader={status=0,QTime=0,params={terms=true,terms.fl=name,wt=javabin,version=2}},response={numFound=0,start=0,docs=[]}}
numFound: 0
Exception in thread "main" java.lang.NullPointerException
at solr_test.solr.test4.main(test4.java:29)

Reply via email to