关于solr加上baseAuth安全认证后怎么用java的org.apache.solr.client.solrj包去访问并查询数据?

2024-12-11 23:55:32
推荐回答(1个)
回答1:

Using BasicAuth with SolrJ
In SolrJ, the basic authentication credentials need to be set for each request as in this example:
SolrRequest req ;//create a new request object req.setBasicAuthCredentials(userName, password); solrClient.request(req);

Query example:
QueryRequest req = new QueryRequest(new SolrQuery("*:*")); req.setBasicAuthCredentials(userName, password); QueryResponse rsp = req.process(solrClient);