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 <peich...@gmail.com> 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
> <eng.huda.bara...@gmail.com> 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: java-user-unsubscr...@lucene.apache.org
> For additional commands, e-mail: java-user-h...@lucene.apache.org
>
>

Reply via email to