lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Wee <peich...@gmail.com>
Subject Re: term frequency
Date Thu, 24 Nov 2016 15:27:00 GMT
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.barakat@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-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message