Ok, I found another way of doing it which will preserve the QueryResponse
object. I've used DefaultHttpClient, set the credentials and finally passed
it as a constructor to the CloudSolrClient.

*DefaultHttpClient httpclient = new DefaultHttpClient();
UsernamePasswordCredentials defaultcreds = new
UsernamePasswordCredentials(USER, PASSWORD);
httpclient.getCredentialsProvider().setCredentials(AuthScope.ANY,
defaultcreds);
SolrClient  client = new CloudSolrClient("127.0.0.1:9983", httpclient);*
SolrClient client = new CloudSolrClient("127.0.0.1:9983"); 
((CloudSolrClient)client).setDefaultCollection("gettingstarted"); 
ModifiableSolrParams param = getSearchSolrQuery(); 
try{ 
          QueryResponse res = client.query(param); 
          //facets 
          List<FacetField> fieldFacets = solrResp.getFacetFields(); 
          // results 
          SolrDocumentList docs = solrResp.getResults(); 
          // Spelling 
          SpellCheckResponse spellCheckResponse =
solrResp.getSpellCheckResponse(); 
  }catch(Exception ex){ 
        ex.printStackTrace(); 
  }finally{ 
       try { 
            client.close(); 
      } catch (IOException e) { 
             e.printStackTrace(); 
      }
  } 

Just wanted to know if this is recommended ?



--
View this message in context: 
http://lucene.472066.n3.nabble.com/Solrj-API-with-Basic-Authentication-tp4276312p4276319.html
Sent from the Solr - User mailing list archive at Nabble.com.

Reply via email to