Thank you for fast reply, I add the query in the code but still not working: ////////////////////////////////////////////////////////////
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 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.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()); } } /////////////////////////////////////////////////////////////// I got this error: numFound: 32 Exception in thread "main" java.lang.NullPointerException at testPkg.App3.main(App3.java:30) On 5 January 2017 at 18:25, Ahmet Arslan <iori...@yahoo.com.invalid> wrote: > Hi, > > I think you are missing the main query parameter? q=*:* > > By the way you may get more response in the sole-user mailing list. > > Ahmet > > > On Wednesday, January 4, 2017 4:59 PM, huda barakat < > eng.huda.bara...@gmail.com> wrote: > 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) > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org > For additional commands, e-mail: java-user-h...@lucene.apache.org > >