Hello Huda, Try to check this https://github.com/apache/lucene-solr/blob/master/solr/solrj/src/test/org/apache/solr/client/solrj/response/TermsResponseTest.java
On Mon, Jan 9, 2017 at 4:31 PM, huda barakat <eng.huda.bara...@gmail.com> wrote: > Hi, > Can anybody help me, I need to get term frequency for a specific filed, I > use the techproduct example and I use this code: > > //////////////////////////////////////////////////////////// > ////////////////// > import java.util.List; > import org.apache.solr.client.solrj.SolrClient; > import org.apache.solr.client.solrj.SolrQuery; > import org.apache.solr.client.solrj.impl.HttpSolrClient; > import org.apache.solr.client.solrj.response.QueryResponse; > import org.apache.solr.client.solrj.response.TermsResponse; > > public class App3 { > 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.setQuery("*:*"); > > query.setRequestHandler("terms"); > > > QueryResponse response = solr.query(query); > System.out.println("numFound: " + > response.getResults().getNumFound()); > > TermsResponse termResp =response.getTermsResponse(); > > List<TermsResponse.Term> terms = termResp.getTerms("name"); > System.out.print("size="+ terms.size()); > > > } > } > //////////////////////////////////////////////////////////// > > I get the following error : > > Exception in thread "main" numFound: 32 > java.lang.NullPointerException > at testPkg.App3.main(App3.java:29) > > > Thank you in advance,,, > Huda > -- Sincerely yours Mikhail Khludnev