lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ahmet Arslan <>
Subject Re: term frequency in solr
Date Thu, 05 Jan 2017 17:25:27 GMT

I think you are missing the main query parameter? q=*:*

By the way you may get more response in the sole-user mailing list.


On Wednesday, January 4, 2017 4:59 PM, huda barakat <> 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();
        SolrRequest<QueryResponse> req = new QueryRequest(query);
        QueryResponse rsp = req.process(solr);


        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 for further
numFound: 0
Exception in thread "main" java.lang.NullPointerException
at solr_test.solr.test4.main(

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message