Home
Cloud
Big Data
CI
Install
Samples
Java
Ubuntu
Maven
Archive
Apache Solr
|
SolrJ: Search documents using the request handler /select
Notes
Example
Notes
In order for the code bellow to work:
► Make sure to update the variables ("
solrUrl
", "
collectionName
", ...) with your information.
Example
Search documents using the request handler
/select
:
final String SELECT_REQUEST_PATH = "/select"; final String[] solrUrl = { "http://localhost:8983/solr" }; final String collectionName = "collection1"; final CloudSolrClient cloudSolrClient = new CloudSolrClient.Builder(Arrays.asList(solrUrl)).build(); cloudSolrClient.setDefaultCollection(collectionName); // selecting documents [/select] [ModifiableSolrParams] { final ModifiableSolrParams modifiableSolrParams = new ModifiableSolrParams(); modifiableSolrParams.add(CommonParams.Q, "*:*"); modifiableSolrParams.add(CoreAdminParams.COLLECTION, collectionName); final QueryRequest queryRequest = new QueryRequest(modifiableSolrParams, METHOD.POST); queryRequest.setPath(SELECT_REQUEST_PATH); final QueryResponse queryResponse = queryRequest.process(cloudSolrClient); System.out.println(queryResponse); } cloudSolrClient.close();
© 2010-2022
mti
tek