Solr 4 with basic authentication

前端 未结 3 1301
野趣味
野趣味 2021-01-20 08:27

I am trying to connect to solr using solrj. My solr instance runs in jetty and is protected with basic authentication. I found these links that contain relevant information.

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-20 08:52

    You need to add the JAR solr-solrj-4.0.0.jar for HttpClientUtil.

    Then use the below code:

    HttpSolrServer solrServer = new HttpSolrServer("http://localhost:8080/solr/"+url);     
    HttpClientUtil.setBasicAuth((DefaultHttpClient) solrServer.getHttpClient(), "USERNAME", "PASSWORD");
    

    That worked for me on Jdk 1.6 and tomcat 6

提交回复
热议问题