This the error I get it is the same:
Exception in thread "main" java.lang.NullPointerException
at solr_test.solr.SolrJTermsApplication.main(SolrJTermsApplication.java:30)
I know the object is null but I don't know why it is null??
when I change the query to this:
SolrQuery query = new SolrQuery();
query.setQuery("*:*");
SolrRequest<QueryResponse> req = new QueryRequest(query);
QueryResponse rsp = req.process(solr);
System.out.println("numFound: " +
rsp.getResults().getNumFound());
I get results but the problem I want to get term frequency in the field
"name" how can I do that???
Thank you!
On 24 November 2016 at 16:27, Jason Wee <[email protected]> wrote:
> the exception line does not match the code you pasted, but do make
> sure your object actually not null before accessing its method.
>
> On Thu, Nov 24, 2016 at 5:42 PM, huda barakat
> <[email protected]> wrote:
> > I'm using SOLRJ to find term frequency for each term in a field, I wrote
> > this code but it is not working:
> >
> >
> > 1. String urlString = "http://localhost:8983/solr/huda";
> > 2. SolrClient solr = new HttpSolrClient.Builder(
> urlString).build();
> > 3.
> > 4. SolrQuery query = new SolrQuery();
> > 5. query.setTerms(true);
> > 6. query.addTermsField("name");
> > 7. SolrRequest<QueryResponse> req = new QueryRequest(query);
> > 8. QueryResponse rsp = req.process(solr);
> > 9.
> > 10. System.out.println(rsp);
> > 11.
> > 12. System.out.println("numFound: " +
> > rsp.getResults().getNumFound());
> > 13.
> > 14. TermsResponse termResp =rsp.getTermsResponse();
> > 15. List<TermsResponse.Term> terms =
> termResp.getTerms("name");
> > 16. System.out.print(terms.size());
> >
> >
> > I got this error:
> >
> > Exception in thread "main" java.lang.NullPointerException at
> > solr_test.solr.App2.main(App2.java:50)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>